diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index f5a28f8d52d..8af21172df4 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -39,5 +39,3 @@ function createCancellationToken(args) { }; } module.exports = createCancellationToken; - -//# sourceMappingURL=cancellationToken.js.map 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.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 499d0de52db..82e2761b759 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -225,13 +225,13 @@ interface NumberConstructor { * number. Only finite values of the type number, result in true. * @param number A numeric value. */ - isFinite(number: number): boolean; + isFinite(value: any): value is number; /** * Returns true if the value passed is an integer, false otherwise. * @param number A numeric value. */ - isInteger(number: number): boolean; + isInteger(value: any): value is number; /** * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a @@ -239,13 +239,13 @@ interface NumberConstructor { * to a number. Only values of the type number, that are also NaN, result in true. * @param number A numeric value. */ - isNaN(number: number): boolean; + isNaN(value: any): value is number; /** * Returns true if the value passed is a safe integer. * @param number A numeric value. */ - isSafeInteger(number: number): boolean; + isSafeInteger(value: any): value is number; /** * The value of the largest integer n such that n and n + 1 are both exactly representable as diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 03996c6ad9f..6f01f10bfbd 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -19,7 +19,7 @@ and limitations under the License. interface ProxyHandler { - getPrototypeOf? (target: T): any; + getPrototypeOf? (target: T): {} | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -32,11 +32,11 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, argArray: any, newTarget?: any): {}; } interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; new (target: T, handler: ProxyHandler): T } -declare var Proxy: ProxyConstructor; \ No newline at end of file +declare var Proxy: ProxyConstructor; 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.object.d.ts b/lib/lib.es2017.object.d.ts index 996147a9746..dc3806835ef 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -29,6 +29,6 @@ interface ObjectConstructor { * Returns an array of key/values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - entries(o: { [s: string]: T }): [string, T][]; + entries(o: T): [keyof T, T[K]][]; entries(o: any): [string, any][]; -} \ 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 1ace5f499b1..27a57bd914e 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -4362,13 +4362,13 @@ interface NumberConstructor { * number. Only finite values of the type number, result in true. * @param number A numeric value. */ - isFinite(number: number): boolean; + isFinite(value: any): value is number; /** * Returns true if the value passed is an integer, false otherwise. * @param number A numeric value. */ - isInteger(number: number): boolean; + isInteger(value: any): value is number; /** * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a @@ -4376,13 +4376,13 @@ interface NumberConstructor { * to a number. Only values of the type number, that are also NaN, result in true. * @param number A numeric value. */ - isNaN(number: number): boolean; + isNaN(value: any): value is number; /** * Returns true if the value passed is a safe integer. * @param number A numeric value. */ - isSafeInteger(number: number): boolean; + isSafeInteger(value: any): value is number; /** * The value of the largest integer n such that n and n + 1 are both exactly representable as @@ -5471,7 +5471,7 @@ interface PromiseConstructor { declare var Promise: PromiseConstructor; interface ProxyHandler { - getPrototypeOf? (target: T): any; + getPrototypeOf? (target: T): {} | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; @@ -5484,14 +5484,15 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, argArray: any, newTarget?: any): {}; } interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; new (target: T, handler: ProxyHandler): T } -declare var Proxy: ProxyConstructor; +declare var Proxy: ProxyConstructor; + declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; @@ -7555,6 +7556,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 +7626,7 @@ declare var CanvasGradient: { } interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; } declare var CanvasPattern: { @@ -8049,7 +8052,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 +14481,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 +14594,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 +14612,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 +18733,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 +19035,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 +20182,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/protocol.d.ts b/lib/protocol.d.ts index 2b57b5de644..0d5c5fbfc0e 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -59,7 +59,7 @@ declare namespace ts.server.protocol { /** * One of "request", "response", or "event" */ - type: string; + type: "request" | "response" | "event"; } /** * Client-initiated request message @@ -653,7 +653,7 @@ declare namespace ts.server.protocol { /** * Script kind of the file */ - scriptKind?: ScriptKind; + scriptKind?: ScriptKindName | ts.ScriptKind; /** * Whether file has mixed content (i.e. .cshtml file that combines html markup with C#/JavaScript) */ @@ -684,37 +684,17 @@ declare namespace ts.server.protocol { */ typingOptions?: TypingOptions; } - /** - * For external projects, some of the project settings are sent together with - * compiler settings. - */ - interface ExternalProjectCompilerOptions extends CompilerOptions { + interface CompileOnSaveMixin { /** * If compile on save is enabled for the project */ compileOnSave?: boolean; } /** - * Contains information about current project version + * For external projects, some of the project settings are sent together with + * compiler settings. */ - interface ProjectVersionInfo { - /** - * Project name - */ - projectName: string; - /** - * true if project is inferred or false if project is external or configured - */ - isInferred: boolean; - /** - * Project version - */ - version: number; - /** - * Current set of compiler options for project - */ - options: CompilerOptions; - } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; /** * Represents a set of changes that happen in project */ @@ -728,36 +708,6 @@ declare namespace ts.server.protocol { */ removed: string[]; } - /** - * Describes set of files in the project. - * info might be omitted in case of inferred projects - * if files is set - then this is the entire set of files in the project - * if changes is set - then this is the set of changes that should be applied to existing project - * otherwise - assume that nothing is changed - */ - interface ProjectFiles { - /** - * Information abount project verison - */ - info?: ProjectVersionInfo; - /** - * List of files in project (might be omitted if current state of project can be computed using only information from 'changes') - */ - files?: string[]; - /** - * Set of changes in project (omitted if the entire set of files in project should be replaced) - */ - changes?: ProjectChanges; - } - /** - * Combines project information with project level errors. - */ - interface ProjectFilesWithDiagnostics extends ProjectFiles { - /** - * List of errors in project - */ - projectErrors: DiagnosticWithLinePosition[]; - } /** * Information found in a configure request. */ @@ -803,8 +753,9 @@ declare namespace ts.server.protocol { * Used to specify the script kind of the file explicitly. It could be one of the following: * "TS", "JS", "TSX", "JSX" */ - scriptKindName?: "TS" | "JS" | "TSX" | "JSX"; + scriptKindName?: ScriptKindName; } + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; /** * Open request; value of command field is "open". Notify the * server that the client has file open. The server will not @@ -878,15 +829,6 @@ declare namespace ts.server.protocol { */ interface CloseExternalProjectResponse extends Response { } - /** - * Arguments to SynchronizeProjectListRequest - */ - interface SynchronizeProjectListRequestArgs { - /** - * List of last known projects - */ - knownProjects: protocol.ProjectVersionInfo[]; - } /** * Request to set compiler options for inferred projects. * External projects are opened / closed explicitly. @@ -1669,12 +1611,158 @@ declare namespace ts.server.protocol { spans: TextSpan[]; childItems?: NavigationTree[]; } + type TelemetryEventName = "telemetry"; + interface TelemetryEvent extends Event { + event: TelemetryEventName; + body: TelemetryEventBody; + } + interface TelemetryEventBody { + telemetryEventName: string; + payload: any; + } + type TypingsInstalledTelemetryEventName = "typingsInstalled"; + interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { + telemetryEventName: TypingsInstalledTelemetryEventName; + payload: TypingsInstalledTelemetryEventPayload; + } + interface TypingsInstalledTelemetryEventPayload { + /** + * Comma separated list of installed typing packages + */ + installedPackages: string; + /** + * true if install request succeeded, otherwise - false + */ + installSuccess: boolean; + } interface NavBarResponse extends Response { body?: NavigationBarItem[]; } interface NavTreeResponse extends Response { body?: NavigationTree; } + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; + } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + /** Paths used to used to compute primary types search locations */ + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } declare namespace ts.server.protocol { @@ -1695,29 +1783,6 @@ declare namespace ts.server.protocol { position: number; } - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle; - } - - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, - } - - enum ScriptKind { - Unknown = 0, - JS = 1, - JSX = 2, - TS = 3, - TSX = 4, - } - interface TypingOptions { enableAutoDiscovery?: boolean; include?: string[]; @@ -1725,124 +1790,22 @@ declare namespace ts.server.protocol { [option: string]: string[] | boolean | undefined; } - interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - alwaysStrict?: boolean; - baseUrl?: string; - charset?: string; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - importHelpers?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind; - moduleResolution?: ModuleResolutionKind; - newLine?: NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - preserveConstEnums?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strictNullChecks?: boolean; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget; - traceResolution?: boolean; - types?: string[]; - /** Paths used to used to compute primary types search locations */ - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; - } - - enum JsxEmit { - None = 0, - Preserve = 1, - React = 2, - } - - enum ModuleKind { - None = 0, - CommonJS = 1, - AMD = 2, - UMD = 3, - System = 4, - ES6 = 5, - ES2015 = 5, - } - - enum ModuleResolutionKind { - Classic = 1, - NodeJs = 2, - } - - enum NewLineKind { - CarriageReturnLineFeed = 0, - LineFeed = 1, - } - interface MapLike { [index: string]: T; } - enum ScriptTarget { - ES3 = 0, - ES5 = 1, - ES6 = 2, - ES2015 = 2, - Latest = 2, - } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; - - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - } -} \ No newline at end of file +} +declare namespace ts { + // these types are empty stubs for types from services and should not be used directly + export type ScriptKind = never; + export type IndentStyle = never; + export type JsxEmit = never; + export type ModuleKind = never; + export type ModuleResolutionKind = never; + export type NewLineKind = never; + export type ScriptTarget = never; +} +import protocol = ts.server.protocol; +export = protocol; +export as namespace protocol; \ No newline at end of file diff --git a/lib/tsc.js b/lib/tsc.js index fbfe07a4588..98b51ba9216 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -15,418 +15,6 @@ and limitations under the License. var ts; (function (ts) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - 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["QualifiedName"] = 140] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; - 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["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["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; - 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["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; - 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["ExternalModuleReference"] = 241] = "ExternalModuleReference"; - 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["CaseClause"] = 249] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; - 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["SyntaxList"] = 286] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; - SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - 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; - (function (NodeFlags) { - NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Let"] = 1] = "Let"; - NodeFlags[NodeFlags["Const"] = 2] = "Const"; - NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; - NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; - NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; - 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["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; - NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; - NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; - (function (ModifierFlags) { - ModifierFlags[ModifierFlags["None"] = 0] = "None"; - ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; - ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; - ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; - ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; - ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; - ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; - ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; - ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; - ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; - ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; - ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; - ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; - ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; - })(ts.ModifierFlags || (ts.ModifierFlags = {})); - var ModifierFlags = ts.ModifierFlags; - (function (JsxFlags) { - JsxFlags[JsxFlags["None"] = 0] = "None"; - JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; - JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; - (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; - (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; - (function (FlowFlags) { - FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; - FlowFlags[FlowFlags["Start"] = 2] = "Start"; - FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; - FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; - FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; - FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; - FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; - FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["Label"] = 12] = "Label"; - FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; - })(ts.FlowFlags || (ts.FlowFlags = {})); - var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -439,38 +27,6 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; - (function (TypeFormatFlags) { - TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; - TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; - TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; - TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; - TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; - TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; - TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; - TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; - TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; - TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - (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; - (function (TypePredicateKind) { - TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; - TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; - })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); - var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -485,166 +41,6 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; - (function (SymbolFlags) { - SymbolFlags[SymbolFlags["None"] = 0] = "None"; - SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; - SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; - SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; - SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; - SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; - SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; - SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; - SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; - SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; - SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; - SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; - SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; - SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; - SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; - SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; - SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; - SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; - SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; - SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; - SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; - SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; - SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; - SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; - SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; - SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; - SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; - SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; - SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; - SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; - SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; - SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; - SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; - SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; - SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; - SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; - SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; - SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; - SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; - SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; - SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; - NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; - NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; - NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; - (function (TypeFlags) { - TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["Void"] = 1024] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 4096] = "Null"; - TypeFlags[TypeFlags["Never"] = 8192] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 32768] = "Class"; - TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 524288] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; - TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; - TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; - TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; - TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; - TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; - TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; - TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; - TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; - (function (SignatureKind) { - SignatureKind[SignatureKind["Call"] = 0] = "Call"; - SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; - (function (IndexKind) { - IndexKind[IndexKind["String"] = 0] = "String"; - IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; - (function (SpecialPropertyAssignmentKind) { - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; - })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); - var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -665,264 +61,15 @@ var ts; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; - (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; - (function (NewLineKind) { - NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; - NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; - })(ts.NewLineKind || (ts.NewLineKind = {})); - var NewLineKind = ts.NewLineKind; - (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; - (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; - (function (LanguageVariant) { - LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; - LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; - })(ts.LanguageVariant || (ts.LanguageVariant = {})); - var LanguageVariant = ts.LanguageVariant; - (function (DiagnosticStyle) { - DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; - DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; - })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); - var DiagnosticStyle = ts.DiagnosticStyle; - (function (WatchDirectoryFlags) { - WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; - WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; - })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); - var WatchDirectoryFlags = ts.WatchDirectoryFlags; - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; - CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; - CharacterCodes[CharacterCodes["space"] = 32] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; - CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; - CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; - CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; - CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; - CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; - CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; - CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["j"] = 106] = "j"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["B"] = 66] = "B"; - CharacterCodes[CharacterCodes["C"] = 67] = "C"; - CharacterCodes[CharacterCodes["D"] = 68] = "D"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["G"] = 71] = "G"; - CharacterCodes[CharacterCodes["H"] = 72] = "H"; - CharacterCodes[CharacterCodes["I"] = 73] = "I"; - CharacterCodes[CharacterCodes["J"] = 74] = "J"; - CharacterCodes[CharacterCodes["K"] = 75] = "K"; - CharacterCodes[CharacterCodes["L"] = 76] = "L"; - CharacterCodes[CharacterCodes["M"] = 77] = "M"; - CharacterCodes[CharacterCodes["N"] = 78] = "N"; - CharacterCodes[CharacterCodes["O"] = 79] = "O"; - CharacterCodes[CharacterCodes["P"] = 80] = "P"; - CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; - CharacterCodes[CharacterCodes["R"] = 82] = "R"; - CharacterCodes[CharacterCodes["S"] = 83] = "S"; - CharacterCodes[CharacterCodes["T"] = 84] = "T"; - CharacterCodes[CharacterCodes["U"] = 85] = "U"; - CharacterCodes[CharacterCodes["V"] = 86] = "V"; - CharacterCodes[CharacterCodes["W"] = 87] = "W"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; - (function (TransformFlags) { - TransformFlags[TransformFlags["None"] = 0] = "None"; - TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; - 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["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["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - 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["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["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["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; - })(ts.TransformFlags || (ts.TransformFlags = {})); - var TransformFlags = ts.TransformFlags; - (function (EmitFlags) { - EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; - EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; - EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; - EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; - EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; - EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; - EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; - EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; - EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; - EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; - EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; - EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; - EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; - EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; - EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; - EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; - EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; - EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; - EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; - EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; - EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; - EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.EmitFlags || (ts.EmitFlags = {})); - var EmitFlags = ts.EmitFlags; - (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; + (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) { @@ -985,12 +132,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - (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; var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { @@ -1055,12 +196,6 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; - (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; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -1073,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++) { @@ -1332,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); } @@ -1368,6 +515,41 @@ var ts; return result; } ts.deduplicate = deduplicate; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function changesAffectModuleResolution(oldOptions, newOptions) { + return !oldOptions || + (oldOptions.module !== newOptions.module) || + (oldOptions.moduleResolution !== newOptions.moduleResolution) || + (oldOptions.noResolve !== newOptions.noResolve) || + (oldOptions.target !== newOptions.target) || + (oldOptions.noLib !== newOptions.noLib) || + (oldOptions.jsx !== newOptions.jsx) || + (oldOptions.allowJs !== newOptions.allowJs) || + (oldOptions.rootDir !== newOptions.rootDir) || + (oldOptions.configFilePath !== newOptions.configFilePath) || + (oldOptions.baseUrl !== newOptions.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) || + !arrayIsEqualTo(oldOptions.lib, newOptions.lib) || + !arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) || + !equalOwnProperties(oldOptions.paths, newOptions.paths); + } + ts.changesAffectModuleResolution = changesAffectModuleResolution; function compact(array) { var result; if (array) { @@ -1386,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++) { @@ -1395,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) { @@ -1422,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] @@ -1434,17 +650,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; + function replaceElement(array, index, value) { + var result = array.slice(0); + result[index] = value; + return result; } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value, comparer) { + ts.replaceElement = replaceElement; + 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 @@ -1678,6 +894,12 @@ var ts; return Array.isArray ? Array.isArray(value) : value instanceof Array; } ts.isArray = isArray; + function noop() { } + ts.noop = noop; + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; function memoize(callback) { var value; return function () { @@ -1793,6 +1015,17 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText + }; + } + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; function chainDiagnosticMessages(details, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -2185,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); } @@ -2212,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); } @@ -2340,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; } @@ -2408,14 +1665,6 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; - (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; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -2466,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); } @@ -2504,13 +1749,6 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; - (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; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2622,6 +1860,36 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + var ext = tryGetExtensionFromPath(path); + if (ext !== undefined) { + return ext; + } + Debug.fail("File " + path + " has unknown extension."); + } + ts.extensionFromPath = extensionFromPath; + function tryGetExtensionFromPath(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; + } + } + ts.tryGetExtensionFromPath = tryGetExtensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2895,11 +2163,6 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } - var FileSystemEntryKind; - (function (FileSystemEntryKind) { - FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; - FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; - })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2921,6 +2184,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, @@ -2930,7 +2194,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 { @@ -2938,7 +2202,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); } }; @@ -2953,7 +2217,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 }; @@ -3030,7 +2294,9 @@ var ts; } catch (e) { } - } + }, + setTimeout: setTimeout, + clearTimeout: clearTimeout }; return nodeSystem; } @@ -3148,7 +2414,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." }, @@ -3258,7 +2524,6 @@ var ts; Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, @@ -3376,14 +2641,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}'" }, @@ -3423,7 +2688,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" }, @@ -3461,8 +2726,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." }, @@ -3474,7 +2737,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." }, @@ -3496,9 +2759,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." }, @@ -3545,6 +2806,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." }, @@ -3568,6 +2836,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." }, @@ -3599,6 +2868,10 @@ 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." }, + An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, 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}'." }, @@ -3698,6 +2971,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." }, @@ -3781,7 +3055,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." }, @@ -3818,11 +3092,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." }, @@ -3831,7 +3110,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." }, @@ -3878,6 +3158,8 @@ var ts; Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, @@ -3885,6 +3167,8 @@ var ts; Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, 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; @@ -3917,7 +3201,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -3927,34 +3211,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, @@ -3962,7 +3247,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -5345,10 +4630,13 @@ var ts; case 44: pos++; return token = 25; + case 46: + 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; @@ -5466,11 +4754,11 @@ var ts; writeParameter: writeText, writeSymbol: writeText, writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; } return stringWriters.pop(); @@ -5485,22 +4773,6 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; function hasResolvedModule(sourceFile, moduleNameText) { return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); } @@ -5524,7 +4796,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) { @@ -5550,21 +4824,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 !== 261) { node = node.parent; } return node; @@ -5572,11 +4846,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 200: - case 228: - case 207: - case 208: - case 209: + case 204: + case 232: + case 211: + case 212: + case 213: return true; } return false; @@ -5641,18 +4915,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 === 291 && 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 >= 262 && node.kind <= 287; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; + return node.kind >= 278 && node.kind <= 290; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5741,11 +5015,16 @@ var ts; ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclaration(declaration); + isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 223 && node.parent.kind === 256; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 && + return node && node.kind === 230 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5754,11 +5033,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 226 && (!node.body); + return node.kind === 230 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 226 || + return node.kind === 261 || + node.kind === 230 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5771,9 +5050,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256: + case 261: return ts.isExternalModule(node.parent); - case 227: + case 231: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5781,22 +5060,22 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isBlockScope(node, parentNode) { switch (node.kind) { + case 261: + case 232: case 256: - case 228: - case 252: - case 226: - case 207: - case 208: - case 209: - case 149: - case 148: + case 230: + case 211: + case 212: + case 213: case 150: + case 149: case 151: - case 221: - case 180: - case 181: + case 152: + case 225: + case 184: + case 185: return true; - case 200: + case 204: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5812,23 +5091,46 @@ var ts; } } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 219 && - declaration.parent && - declaration.parent.kind === 252; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { 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 177: + 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); @@ -5851,7 +5153,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 === 204) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5863,29 +5165,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256: + case 261: 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 174: case 226: + case 197: + case 227: + case 230: + case 229: + case 260: case 225: - case 255: - case 221: - case 180: - case 148: - case 150: + case 184: + case 149: case 151: - case 224: + case 152: + case 228: errorNode = node.name; break; - case 181: + case 185: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5906,7 +5208,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 && isConst(node); + return node.kind === 229 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5919,11 +5221,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 && n.expression.kind === 96; + return n.kind === 179 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 203 && node.expression.kind === 9; + return node.kind === 207 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5939,10 +5241,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 === 184 || + node.kind === 185) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -5957,69 +5259,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 <= 171) { 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 !== 188; + case 199: 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 === 177 && 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 === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141: + case 177: 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 <= 171) { return true; } switch (parent_1.kind) { - case 195: + case 199: 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 223: return node === parent_1.type; - case 221: - case 180: - case 181: + case 225: + case 184: + case 185: + 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 178: + case 182: return node === parent_1.type; - case 175: - case 176: + case 179: + case 180: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 177: + case 181: return false; } } @@ -6030,23 +5332,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212: + case 216: return visitor(node); - case 228: - case 200: + case 232: case 204: - case 205: - case 206: - case 207: case 208: case 209: + case 210: + case 211: + case 212: case 213: - case 214: - case 249: - case 250: - case 215: case 217: - case 252: + case 218: + case 253: + case 254: + case 219: + case 221: + case 256: return ts.forEachChild(node, traverse); } } @@ -6056,23 +5358,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191: + case 195: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 225: - case 223: + case 229: + case 227: + case 230: + case 228: case 226: - case 224: - case 222: - case 193: + case 197: 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; } @@ -6087,14 +5389,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 170: - case 255: - case 143: - case 253: + case 174: + case 260: + case 144: + case 257: + case 147: case 146: - case 145: - case 254: - case 219: + case 258: + case 223: return true; } } @@ -6102,11 +5404,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 === 226 || node.kind === 197); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6115,19 +5417,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 184: + case 225: + case 185: + case 149: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return true; } return false; @@ -6135,13 +5437,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 225: + case 184: return true; } return false; @@ -6149,30 +5451,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 207: - case 208: + case 211: + case 212: + case 213: case 209: - case 205: - case 206: + case 210: return true; - case 215: + case 219: 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 === 204 && 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 === 176; } 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 === 176 || + node.parent.kind === 197); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6208,39 +5510,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 185: if (!includeArrowFunctions) { continue; } - case 221: - case 180: - case 226: - case 146: - case 145: - case 148: + case 225: + case 184: + case 230: 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 229: + case 261: return node; } } @@ -6253,25 +5555,25 @@ var ts; return node; } switch (node.kind) { - case 141: + case 142: node = node.parent; break; - case 221: - case 180: - case 181: + case 225: + case 184: + case 185: 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)) { @@ -6283,14 +5585,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 || func.kind === 181) { + if (func.kind === 184 || func.kind === 185) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 179) { + while (parent_2.kind === 183) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 175 && parent_2.expression === prev) { + if (parent_2.kind === 179 && parent_2.expression === prev) { return parent_2; } } @@ -6298,32 +5600,32 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 || kind === 174) + return (kind === 177 || kind === 178) && 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 272: + return node.typeName; + case 199: + 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 179: + case 180: + case 181: + case 145: return true; default: return false; @@ -6331,7 +5633,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177) { + if (node.kind === 181) { return node.tag; } return node.expression; @@ -6339,21 +5641,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222: + case 226: return true; - case 146: - return node.parent.kind === 222; - case 150: + case 147: + return node.parent.kind === 226; case 151: - case 148: + case 152: + case 149: return node.body !== undefined - && node.parent.kind === 222; - case 143: + && node.parent.kind === 226; + 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 === 226; } return false; } @@ -6369,19 +5671,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222: + case 226: 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 === 248 || + parent.kind === 247 || + parent.kind === 249) { return parent.tagName === node; } return false; @@ -6395,43 +5697,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 181: - case 184: + case 200: case 182: + case 201: case 183: + case 184: + case 197: + case 185: + case 188: case 186: case 187: - case 188: - case 189: - case 192: case 190: - case 12: - case 194: - case 242: - case 243: case 191: - case 185: + case 192: + case 193: + case 196: + case 194: + case 12: + case 198: + case 246: + case 247: + case 195: + case 189: 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: @@ -6439,47 +5741,47 @@ var ts; case 98: var parent_3 = node.parent; switch (parent_3.kind) { - case 219: - case 143: + case 223: + case 144: + case 147: case 146: - case 145: - case 255: - case 253: - case 170: + case 260: + case 257: + case 174: 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 210: + case 216: + case 217: + case 218: + case 253: + case 220: + case 218: + return parent_3.expression === node; + case 211: + var forStatement = parent_3; + return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + forStatement.condition === node || + forStatement.incrementor === node; + case 212: + case 213: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || forInStatement.expression === node; - case 178: - case 196: + case 182: + case 200: return node === parent_3.expression; - case 198: + case 202: return node === parent_3.expression; - case 141: + case 142: return node === parent_3.expression; - case 144: - case 248: - case 247: + case 145: + case 252: + case 251: return true; - case 195: + case 199: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -6497,7 +5799,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind === 241; + return node.kind === 234 && node.moduleReference.kind === 245; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -6506,7 +5808,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind !== 241; + return node.kind === 234 && node.moduleReference.kind !== 245; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -6514,11 +5816,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 === 179 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -6530,9 +5832,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219) { + if (s.valueDeclaration && s.valueDeclaration.kind === 223) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180; + return declaration.initializer && declaration.initializer.kind === 184; } return false; } @@ -6541,11 +5843,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 188) { + if (expression.kind !== 192) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { return 0; } var lhs = expr.left; @@ -6561,7 +5863,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 173) { + else if (lhs.expression.kind === 177) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -6577,35 +5879,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231) { + if (node.kind === 235) { return node.moduleSpecifier; } - if (node.kind === 230) { + if (node.kind === 234) { var reference = node.moduleReference; - if (reference.kind === 241) { + if (reference.kind === 245) { return reference.expression; } } - if (node.kind === 237) { + if (node.kind === 241) { return node.moduleSpecifier; } - if (node.kind === 226 && node.name.kind === 9) { + if (node.kind === 230 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230) { + if (node.kind === 234) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 + return node.kind === 235 && node.importClause && !!node.importClause.name; } @@ -6613,13 +5915,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 143: + case 144: + case 149: case 148: + case 258: + case 257: case 147: - case 254: - case 253: case 146: - case 145: return node.questionToken !== undefined; } } @@ -6627,9 +5929,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 && + return node.kind === 274 && node.parameters.length > 0 && - node.parameters[0].type.kind === 271; + node.parameters[0].type.kind === 276; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -6680,32 +5982,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 === 205; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201; + node.parent.parent.kind === 205; 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 === 230 && + node.parent && node.parent.kind === 230) { 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 === 192 && parent_4.operatorToken.kind === 57 && - parent_4.parent.kind === 203; + parent_4.parent.kind === 207; 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 === 257; 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)); @@ -6730,14 +6032,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 === 280; }); 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 === 280 && tag.parameterName.text === name_6; }); if (paramTags) { return paramTags; } @@ -6747,15 +6049,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); + return getJSDocTag(node, 282, false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); + return getJSDocTag(node, 281, true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); + return getJSDocTag(node, 283, false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -6767,7 +6069,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 === 280) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -6787,13 +6089,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 === 275) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; + return paramTag.typeExpression.type.kind === 275; } } return isDeclaredRestParam(node); @@ -6803,27 +6105,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 192: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 190: + case 191: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 212: + case 213: + return parent.initializer === node ? 1 : 0; + case 183: + case 175: + case 196: + node = parent; + break; + case 258: + if (parent.name !== node) { + return 0; + } + case 257: + 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) { @@ -6836,7 +6155,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 === 261 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6849,7 +6168,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 || parent.kind === 239) { + if (parent.kind === 239 || parent.kind === 243) { if (parent.propertyName) { return true; } @@ -6862,48 +6181,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 260: + case 257: + case 177: 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: - return parent.propertyName === node; + case 174: case 239: + return parent.propertyName === node; + case 243: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 230 || - node.kind === 229 || - node.kind === 232 && !!node.name || + return node.kind === 234 || node.kind === 233 || - node.kind === 235 || + node.kind === 236 && !!node.name || + node.kind === 237 || node.kind === 239 || - node.kind === 236 && exportAssignmentIsAlias(node); + node.kind === 243 || + node.kind === 240 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6989,7 +6308,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) { @@ -7009,7 +6328,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 141 && + return name.kind === 142 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7019,10 +6338,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; @@ -7058,7 +6377,7 @@ var ts; case 113: case 111: case 112: - case 129: + case 130: case 114: return true; } @@ -7067,11 +6386,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 === 174) { node = node.parent.parent; } return node; @@ -7079,15 +6398,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 === 184 + || kind === 225 + || kind === 185 + || kind === 149 || kind === 151 - || kind === 226 - || kind === 256; + || kind === 152 + || kind === 230 + || kind === 261; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -7095,13 +6414,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) { @@ -7136,30 +6455,25 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; - (function (Associativity) { - Associativity[Associativity["Left"] = 0] = "Left"; - Associativity[Associativity["Right"] = 1] = "Right"; - })(ts.Associativity || (ts.Associativity = {})); - var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 180 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176: + case 180: return hasArguments ? 0 : 1; - case 186: - case 183: - case 184: - case 182: - case 185: - case 189: - case 191: - return 1; + case 190: + case 187: case 188: + case 186: + case 189: + case 193: + case 195: + return 1; + case 192: switch (operator) { case 39: case 57: @@ -7183,15 +6497,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 === 180 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188) { + if (expression.kind === 192) { return expression.operatorToken.kind; } - else if (expression.kind === 186 || expression.kind === 187) { + else if (expression.kind === 190 || expression.kind === 191) { return expression.operator; } else { @@ -7209,36 +6523,36 @@ var ts; case 85: case 8: case 9: - case 171: - case 172: - case 180: - case 181: - case 193: - case 242: - case 243: + case 175: + case 176: + case 184: + case 185: + case 197: + case 246: + case 247: 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 182: - case 185: - return 15; + case 198: + return 19; + case 181: + case 177: + case 178: + return 18; + case 180: + return hasArguments ? 18 : 17; + case 179: + return 17; + case 191: + return 16; + case 190: + case 187: case 188: + case 186: + case 189: + return 15; + case 192: switch (operatorKind) { case 50: case 51: @@ -7296,11 +6610,11 @@ var ts; default: return -1; } - case 189: + case 193: return 4; - case 191: + case 195: return 2; - case 192: + case 196: return 1; default: return -1; @@ -7546,20 +6860,30 @@ 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]; - return ts.filter(sourceFiles, isNonDeclarationFile); + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; + return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); + } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; + function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { + return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + } + ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; function isNonDeclarationFile(sourceFile) { return !isDeclarationFile(sourceFile); } + function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { + return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); } function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); @@ -7610,10 +6934,10 @@ 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)) { + if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { onSingleFileEmit(host, sourceFile); } } @@ -7640,7 +6964,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)); }); @@ -7680,7 +7004,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; } }); @@ -7721,10 +7045,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 { @@ -7733,7 +7057,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); @@ -7744,10 +7068,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; } } @@ -7930,7 +7254,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4) { + if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { flags |= 1; } node.modifierFlagsCache = flags | 536870912; @@ -7949,7 +7273,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; } @@ -7965,19 +7289,25 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 && + if (node.kind === 199 && 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 === 176 + || kind === 175; } } return false; @@ -8004,20 +7334,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 173 && isEntityNameExpression(node.expression); + node.kind === 177 && 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 === 177 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172) { + if (kind === 176) { return expression.properties.length === 0; } - if (kind === 171) { + if (kind === 175) { return expression.elements.length === 0; } return false; @@ -8151,39 +7481,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 173) { + else if (kind === 177) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174) { + else if (kind === 178) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 - || kind === 187) { + else if (kind === 190 + || kind === 191) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188) { + else if (kind === 192) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 189) { + else if (kind === 193) { 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 === 188 + || kind === 187 + || kind === 186) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171) { + else if (kind === 175) { return node.elements.length === 0; } - else if (kind === 172) { + else if (kind === 176) { return node.properties.length === 0; } - else if (kind === 175) { + else if (kind === 179) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -8289,23 +7619,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 235: externalImports.push(node); break; - case 230: - if (node.moduleReference.kind === 241) { + case 234: + if (node.moduleReference.kind === 245) { externalImports.push(node); } break; - case 237: + case 241: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -8318,21 +7651,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 240: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; + case 205: + 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 225: + 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 226: + 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 229: + case 230: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -8344,7 +7758,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 === 226 && declaration !== node) { return true; } } @@ -8404,16 +7818,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; @@ -8422,7 +7836,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 141; + || kind === 142; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -8434,57 +7848,58 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 168 - || kind === 169; + || kind === 172 + || kind === 173; } 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 === 203; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 148 - || kind === 150 + return kind === 257 + || kind === 258 + || kind === 259 + || kind === 149 || kind === 151 - || kind === 240; + || kind === 152 + || kind === 244; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 155 && kind <= 167) + return (kind >= 156 && kind <= 171) || kind === 118 - || kind === 131 + || kind === 132 || kind === 121 - || kind === 133 || kind === 134 + || kind === 135 || kind === 104 - || kind === 128 - || kind === 195; + || kind === 129 + || kind === 199; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -8493,94 +7908,102 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 - || kind === 168; + return kind === 173 + || kind === 172; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170; + return node.kind === 174; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 - || kind === 194; + return kind === 174 + || kind === 198; } ts.isArrayBindingElement = isArrayBindingElement; + function isArrayLiteralExpression(node) { + return node.kind === 175; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 176; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173; + return node.kind === 177; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174; + return node.kind === 178; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188; + return node.kind === 192; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189; + return node.kind === 193; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175; + return node.kind === 179; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 + return kind === 194 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192; + function isSpreadExpression(node) { + return node.kind === 196; } - ts.isSpreadElementExpression = isSpreadElementExpression; + ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 195; + return node.kind === 199; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 173 - || kind === 174 - || kind === 176 - || kind === 175 - || kind === 242 - || kind === 243 - || kind === 177 - || kind === 171 - || kind === 179 - || kind === 172 - || kind === 193 + return kind === 177 + || kind === 178 || kind === 180 + || kind === 179 + || kind === 246 + || kind === 247 + || kind === 181 + || kind === 175 + || kind === 183 + || kind === 176 + || kind === 197 + || kind === 184 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 190 + || kind === 194 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 197; + || kind === 201; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 186 + return kind === 190 + || kind === 191 + || kind === 186 || kind === 187 + || kind === 188 + || kind === 189 || kind === 182 - || kind === 183 - || kind === 184 - || kind === 185 - || kind === 178 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -8588,13 +8011,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 189 - || kind === 191 - || kind === 181 - || kind === 188 + return kind === 193 + || kind === 195 + || kind === 185 || kind === 192 || kind === 196 - || kind === 194 + || kind === 200 + || kind === 198 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -8603,16 +8026,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 - || kind === 196; + return kind === 182 + || kind === 200; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288; + return node.kind === 293; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287; + return node.kind === 292; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -8621,15 +8044,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194; + return node.kind === 198; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 198; + return node.kind === 202; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 200; + return node.kind === 204; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8647,119 +8070,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219; + return node.kind === 223; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220; + return node.kind === 224; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228; + return node.kind === 232; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 - || kind === 226; + return kind === 231 + || kind === 230; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230; + return node.kind === 234; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232; + return node.kind === 236; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 - || kind === 233; + return kind === 238 + || kind === 237; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235; + return node.kind === 239; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238; + return node.kind === 242; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239; + return node.kind === 243; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 || node.kind === 225; + return node.kind === 230 || node.kind === 229; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 181 - || kind === 170 - || kind === 222 - || kind === 193 - || kind === 149 - || kind === 225 - || kind === 255 - || kind === 239 - || kind === 221 - || kind === 180 - || kind === 150 - || kind === 232 - || kind === 230 - || kind === 235 - || kind === 223 - || kind === 148 - || kind === 147 + return kind === 185 + || kind === 174 || kind === 226 + || kind === 197 + || kind === 150 || kind === 229 - || kind === 233 - || kind === 143 - || kind === 253 - || kind === 146 - || kind === 145 + || kind === 260 + || kind === 243 + || kind === 225 + || kind === 184 || kind === 151 - || kind === 254 - || kind === 224 - || kind === 142 - || kind === 219 - || kind === 279; + || kind === 236 + || kind === 234 + || kind === 239 + || kind === 227 + || kind === 149 + || kind === 148 + || kind === 230 + || kind === 233 + || kind === 237 + || kind === 144 + || kind === 257 + || kind === 147 + || kind === 146 + || kind === 152 + || kind === 258 + || kind === 228 + || kind === 143 + || kind === 223 + || kind === 284; } function isDeclarationStatementKind(kind) { - return kind === 221 - || kind === 240 - || kind === 222 - || kind === 223 - || kind === 224 - || kind === 225 + return kind === 225 + || kind === 244 || kind === 226 - || kind === 231 + || kind === 227 + || kind === 228 + || kind === 229 || kind === 230 - || kind === 237 - || kind === 236 - || kind === 229; + || kind === 235 + || kind === 234 + || kind === 241 + || kind === 240 + || kind === 233; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 211 - || kind === 210 - || kind === 218 - || kind === 205 - || kind === 203 - || kind === 202 - || kind === 208 + return kind === 215 + || kind === 214 + || kind === 222 || kind === 209 || kind === 207 - || kind === 204 - || kind === 215 - || kind === 212 - || kind === 214 - || kind === 216 - || kind === 217 - || kind === 201 || kind === 206 + || kind === 212 || kind === 213 - || kind === 287; + || kind === 211 + || kind === 208 + || kind === 219 + || kind === 216 + || kind === 218 + || kind === 220 + || kind === 221 + || kind === 205 + || kind === 210 + || kind === 217 + || kind === 292 + || kind === 295 + || kind === 294; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8777,87 +8202,87 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200; + || kind === 204; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 241 - || kind === 140 + return kind === 245 + || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 244; + return node.kind === 248; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245; + return node.kind === 249; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 173; + || kind === 177; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 - || kind === 248 - || kind === 243 + return kind === 246 + || kind === 252 + || kind === 247 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 - || kind === 247; + return kind === 250 + || kind === 251; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247; + return node.kind === 251; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246; + return node.kind === 250; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 248; + || kind === 252; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 - || kind === 250; + return kind === 253 + || kind === 254; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251; + return node.kind === 255; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252; + return node.kind === 256; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 253; + return node.kind === 257; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254; + return node.kind === 258; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 255; + return node.kind === 260; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 256; + return node.kind === 261; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8868,6 +8293,7 @@ var ts; (function (ts) { function getDefaultLibFileName(options) { switch (options.target) { + case 5: case 4: return "lib.es2017.d.ts"; case 3: @@ -8995,9 +8421,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 === 227) { return current; } } @@ -9005,11 +8431,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 === 174 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -9017,14 +8443,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219) { + if (node.kind === 223) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 224) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 205) { flags |= ts.getModifierFlags(node); } return flags; @@ -9033,14 +8459,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219) { + if (node.kind === 223) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 224) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 205) { flags |= node.flags; } return flags; @@ -9052,7 +8478,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 + var ConstructorForKind = kind === 261 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -9222,7 +8648,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; } @@ -9234,12 +8660,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; @@ -9249,16 +8671,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; @@ -9276,7 +8698,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; @@ -9296,7 +8718,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; @@ -9314,7 +8736,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; @@ -9333,7 +8755,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; @@ -9351,7 +8773,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(172, location); node.elements = createNodeArray(elements); return node; } @@ -9364,7 +8786,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169, location); + var node = createNode(173, location); node.elements = createNodeArray(elements); return node; } @@ -9377,7 +8799,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170, location); + var node = createNode(174, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -9393,7 +8815,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171, location); + var node = createNode(175, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -9409,7 +8831,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172, location); + var node = createNode(176, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -9425,7 +8847,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173, location, flags); + var node = createNode(177, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -9442,7 +8864,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174, location); + var node = createNode(178, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -9456,7 +8878,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(179, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -9473,7 +8895,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176, location, flags); + var node = createNode(180, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -9488,7 +8910,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177, location); + var node = createNode(181, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -9502,7 +8924,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179, location); + var node = createNode(183, location); node.expression = expression; return node; } @@ -9515,7 +8937,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(184, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -9534,7 +8956,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(185, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -9552,7 +8974,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182, location); + var node = createNode(186, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -9565,7 +8987,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183, location); + var node = createNode(187, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -9578,7 +9000,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184, location); + var node = createNode(188, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -9591,7 +9013,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185, location); + var node = createNode(189, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -9604,7 +9026,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186, location); + var node = createNode(190, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -9618,7 +9040,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187, location); + var node = createNode(191, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -9634,7 +9056,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(192, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -9649,7 +9071,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189, location); + var node = createNode(193, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -9666,7 +9088,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190, location); + var node = createNode(194, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -9680,7 +9102,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191, location); + var node = createNode(195, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -9694,7 +9116,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192, location); + var node = createNode(196, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -9707,7 +9129,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193, location); + var node = createNode(197, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -9725,12 +9147,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194, location); + var node = createNode(198, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195, location); + var node = createNode(199, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -9744,7 +9166,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(198, location); + var node = createNode(202, location); node.expression = expression; node.literal = literal; return node; @@ -9758,7 +9180,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(200, location, flags); + var block = createNode(204, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -9774,7 +9196,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201, location, flags); + var node = createNode(205, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -9789,7 +9211,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(224, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -9802,7 +9224,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(223, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -9817,11 +9239,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202, location); + return createNode(206, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203, location, flags); + var node = createNode(207, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -9834,7 +9256,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204, location); + var node = createNode(208, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -9849,7 +9271,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205, location); + var node = createNode(209, location); node.statement = statement; node.expression = expression; return node; @@ -9863,7 +9285,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206, location); + var node = createNode(210, location); node.expression = expression; node.statement = statement; return node; @@ -9877,7 +9299,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207, location, undefined); + var node = createNode(211, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9893,7 +9315,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(212, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9908,7 +9330,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9923,7 +9345,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210, location); + var node = createNode(214, location); if (label) { node.label = label; } @@ -9938,7 +9360,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -9953,7 +9375,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -9966,7 +9388,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213, location); + var node = createNode(217, location); node.expression = expression; node.statement = statement; return node; @@ -9980,7 +9402,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214, location); + var node = createNode(218, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9994,7 +9416,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215, location); + var node = createNode(219, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -10008,7 +9430,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216, location); + var node = createNode(220, location); node.expression = expression; return node; } @@ -10021,7 +9443,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217, location); + var node = createNode(221, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -10036,7 +9458,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228, location); + var node = createNode(232, location); node.clauses = createNodeArray(clauses); return node; } @@ -10049,7 +9471,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(225, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10069,7 +9491,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222, location); + var node = createNode(226, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10087,7 +9509,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231, location); + var node = createNode(235, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -10103,7 +9525,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232, location); + var node = createNode(236, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -10117,7 +9539,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233, location); + var node = createNode(237, location); node.name = name; return node; } @@ -10130,7 +9552,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -10143,7 +9565,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235, location); + var node = createNode(239, location); node.propertyName = propertyName; node.name = name; return node; @@ -10157,7 +9579,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236, location); + var node = createNode(240, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -10173,7 +9595,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -10189,7 +9611,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238, location); + var node = createNode(242, location); node.elements = createNodeArray(elements); return node; } @@ -10202,7 +9624,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239, location); + var node = createNode(243, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -10216,7 +9638,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242, location); + var node = createNode(246, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -10231,7 +9653,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(247, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -10245,7 +9667,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -10259,7 +9681,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); + var node = createNode(249, location); node.tagName = tagName; return node; } @@ -10272,7 +9694,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); + var node = createNode(250, location); node.name = name; node.initializer = initializer; return node; @@ -10286,7 +9708,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); + var node = createNode(251, location); node.expression = expression; return node; } @@ -10299,7 +9721,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -10312,7 +9734,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(251, location); + var node = createNode(255, location); node.token = token; node.types = createNodeArray(types); return node; @@ -10326,7 +9748,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249, location); + var node = createNode(253, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -10340,7 +9762,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250, location); + var node = createNode(254, location); node.statements = createNodeArray(statements); return node; } @@ -10353,7 +9775,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); + var node = createNode(256, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -10367,7 +9789,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); + var node = createNode(257, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10382,12 +9804,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); + var node = createNode(258, 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(259, 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); @@ -10395,9 +9823,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(261, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -10459,13 +9894,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(287, original); + var node = createNode(292, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + function createEndOfDeclarationMarker(original) { + var node = createNode(295); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + function createMergeDeclarationMarker(original) { + var node = createNode(294); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); + var node = createNode(293, location || original); node.expression = expression; node.original = original; return node; @@ -10537,10 +9986,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 @@ -10573,10 +10018,23 @@ var ts; function createReactNamespace(reactNamespace, parent) { var react = createIdentifier(reactNamespace || "React"); react.flags &= ~8; - react.parent = parent; + 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); @@ -10596,9 +10054,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); } @@ -10670,13 +10140,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([ @@ -10685,20 +10155,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 @@ -10724,13 +10194,13 @@ var ts; case 8: case 9: return false; - case 171: + case 175: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172: + case 176: return target.properties.length > 0; default: return true; @@ -10750,7 +10220,7 @@ var ts; } else { switch (callee.kind) { - case 173: { + case 177: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -10761,7 +10231,7 @@ var ts; } break; } - case 174: { + case 178: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -10811,14 +10281,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 257: return createExpressionForPropertyAssignment(property, receiver); - case 254: + case 258: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148: + case 149: return createExpressionForMethodDeclaration(property, receiver); } } @@ -10859,6 +10329,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"; } @@ -10920,7 +10443,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 179) { + if (skipped.kind === 183) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -10929,15 +10452,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(192, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, 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 === 195) { return false; } return true; @@ -10976,7 +10499,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.kind === 192 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -10993,9 +10516,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175: + case 179: return createParen(expression); - case 176: + case 180: return emittedExpression.arguments ? expression : createParen(expression); @@ -11006,7 +10529,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && (emittedExpression.kind !== 180 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -11044,7 +10567,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(192, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -11055,7 +10578,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 || kind === 181) { + if (kind === 184 || kind === 185) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -11063,7 +10586,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { return createParen(expression, expression); } } @@ -11081,21 +10604,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187: + case 191: node = node.operand; continue; - case 188: + case 192: node = node.left; continue; - case 189: + case 193: node = node.condition; continue; - case 175: - case 174: - case 173: + case 179: + case 178: + case 177: node = node.expression; continue; - case 288: + case 293: node = node.expression; continue; } @@ -11104,19 +10627,12 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172) { + if (emittedBody.kind === 176) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; - (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; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -11136,7 +10652,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179) { + while (node.kind === 183) { node = node.expression; } return node; @@ -11150,7 +10666,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { + while (node.kind === 293) { node = node.expression; } return node; @@ -11206,7 +10722,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { + if (node.kind === 261) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -11296,13 +10812,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 === 235 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 && node.moduleSpecifier) { + if (node.kind === 241 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -11340,6 +10856,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 === 185); + 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 !== 185) { + 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) { @@ -11348,13 +11079,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256) { + if (kind === 261) { 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 { @@ -11390,26 +11121,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 258: 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 259: + return visitNode(cbNode, node.expression); + case 144: + case 147: case 146: - case 145: - case 253: - case 219: - case 170: + case 257: + case 223: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -11418,24 +11151,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 184: + case 225: + case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -11446,308 +11179,318 @@ 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.readonlyToken) || + visitNode(cbNode, node.typeParameter) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type); case 171: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.literal); case 172: - return visitNodes(cbNodes, node.properties); case 173: + return visitNodes(cbNodes, node.elements); + case 175: + return visitNodes(cbNodes, node.elements); + case 176: + return visitNodes(cbNodes, node.properties); + case 177: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174: + case 178: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175: - case 176: + case 179: + case 180: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177: + case 181: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178: + case 182: 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 187: - return visitNode(cbNode, node.operand); + return visitNode(cbNode, node.expression); case 188: + return visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.operand); + case 195: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 189: + return visitNode(cbNode, node.expression); + case 191: + return visitNode(cbNode, node.operand); + case 192: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196: + case 200: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197: + case 201: return visitNode(cbNode, node.expression); - case 189: + case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192: + case 196: return visitNode(cbNode, node.expression); - case 200: - case 227: + case 204: + case 231: return visitNodes(cbNodes, node.statements); - case 256: + case 261: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201: + case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220: + case 224: return visitNodes(cbNodes, node.declarations); - case 203: + case 207: return visitNode(cbNode, node.expression); - case 204: + case 208: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205: + case 209: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207: + case 211: 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); case 212: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 213: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 228: - return visitNodes(cbNodes, node.clauses); - case 249: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 250: - return visitNodes(cbNodes, node.statements); case 215: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.label); case 216: return visitNode(cbNode, node.expression); case 217: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 232: + return visitNodes(cbNodes, node.clauses); + case 253: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 254: + return visitNodes(cbNodes, node.statements); + case 219: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 220: + return visitNode(cbNode, node.expression); + case 221: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252: + case 256: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144: + case 145: return visitNode(cbNode, node.expression); - case 222: - case 193: + case 226: + case 197: 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: + case 227: 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: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 225: + case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255: + case 260: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 234: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229: - return visitNode(cbNode, node.name); case 233: return visitNode(cbNode, node.name); - case 234: - case 238: - return visitNodes(cbNodes, node.elements); case 237: + return visitNode(cbNode, node.name); + case 238: + case 242: + return visitNodes(cbNodes, node.elements); + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235: case 239: + case 243: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236: + case 240: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190: + case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198: + case 202: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141: + case 142: return visitNode(cbNode, node.expression); - case 251: + case 255: return visitNodes(cbNodes, node.types); - case 195: + case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241: + case 245: return visitNode(cbNode, node.expression); - case 240: + case 244: return visitNodes(cbNodes, node.decorators); - case 242: + case 246: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243: - case 244: + case 247: + case 248: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246: + case 250: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247: + case 251: return visitNode(cbNode, node.expression); - case 248: + case 252: return visitNode(cbNode, node.expression); - case 245: + case 249: 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); - case 268: - return visitNode(cbNode, node.type); - case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); - case 271: - return visitNode(cbNode, node.type); - case 272: return visitNode(cbNode, node.type); case 266: + return visitNodes(cbNodes, node.types); + case 267: + return visitNodes(cbNodes, node.types); + case 265: + return visitNode(cbNode, node.elementType); + case 269: + return visitNode(cbNode, node.type); + case 268: + return visitNode(cbNode, node.type); + case 270: + return visitNode(cbNode, node.literal); + case 272: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 273: + return visitNode(cbNode, node.type); + case 274: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.type); + case 276: + return visitNode(cbNode, node.type); + case 277: + return visitNode(cbNode, node.type); + case 271: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273: + case 278: return visitNodes(cbNodes, node.tags); - case 275: + case 280: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276: + case 281: return visitNode(cbNode, node.typeExpression); - case 277: + case 282: return visitNode(cbNode, node.typeExpression); - case 278: + case 283: return visitNodes(cbNodes, node.typeParameters); - case 279: + case 284: return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281: + case 286: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: + case 285: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288: + case 293: return visitNode(cbNode, node.expression); - case 282: + case 287: return visitNode(cbNode, node.literal); } } @@ -11761,6 +11504,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; } @@ -11783,8 +11530,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; @@ -11808,6 +11555,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; } @@ -11823,7 +11579,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); @@ -11898,7 +11654,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -11918,17 +11674,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) { @@ -11950,41 +11706,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; @@ -12125,7 +11881,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); } @@ -12145,7 +11901,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288; + node.flags |= 1048576; } return node; } @@ -12207,7 +11963,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); @@ -12277,9 +12033,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); @@ -12294,29 +12052,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'."); @@ -12360,7 +12118,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; @@ -12368,31 +12126,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; } } @@ -12409,7 +12168,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; @@ -12460,7 +12219,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 1540096; + var nodeContextFlags = node.flags & 3080192; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -12492,10 +12251,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: @@ -12507,14 +12268,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 203: return true; - case 148: + case 149: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -12526,8 +12287,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249: - case 250: + case 253: + case 254: return true; } } @@ -12536,65 +12297,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221: - case 201: - case 200: + case 225: + case 205: case 204: - case 203: + case 208: + case 207: + case 220: case 216: - case 212: + case 218: + case 215: case 214: + case 212: + case 213: case 211: case 210: - case 208: - case 209: - case 207: - case 206: - case 213: - case 202: case 217: - case 215: - case 205: - case 218: - case 231: - case 230: - case 237: - case 236: - case 226: + case 206: + case 221: + case 219: + case 209: case 222: - case 223: - case 225: - case 224: + case 235: + case 234: + case 241: + case 240: + case 230: + case 226: + case 227: + case 229: + case 228: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255; + return node.kind === 260; } 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 !== 223) { 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; @@ -12614,6 +12375,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; @@ -12625,17 +12387,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; } } ; @@ -12689,7 +12451,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); @@ -12706,7 +12468,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190); + var template = createNode(194); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -12718,7 +12480,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198); + var span = createNode(202); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -12766,33 +12528,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()) { @@ -12806,7 +12568,7 @@ var ts; } function parseTypeParameters() { if (token() === 26) { - return parseBracketedList(17, parseTypeParameter, 26, 28); + return parseBracketedList(18, parseTypeParameter, 26, 28); } } function parseParameterType() { @@ -12819,7 +12581,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(); @@ -12879,7 +12641,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -12919,7 +12681,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); @@ -12931,7 +12693,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; @@ -12940,7 +12702,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; @@ -12980,10 +12742,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(); @@ -12997,7 +12759,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(160); + var node = createNode(161); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -13012,13 +12774,40 @@ var ts; } return members; } + function isStartOfMappedType() { + nextToken(); + if (token() === 130) { + nextToken(); + } + return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; + } + function parseMappedTypeParameter() { + var node = createNode(143); + node.name = parseIdentifier(); + parseExpected(91); + node.constraint = parseType(); + return finishNode(node); + } + function parseMappedType() { + var node = createNode(170); + parseExpected(16); + node.readonlyToken = parseOptionalToken(130); + parseExpected(20); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(21); + node.questionToken = parseOptionalToken(54); + node.type = parseTypeAnnotation(); + parseSemicolon(); + parseExpected(17); + return finishNode(node); + } 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); @@ -13026,7 +12815,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -13037,7 +12826,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167); + var node = createNode(171); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -13048,12 +12837,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: @@ -13078,7 +12867,7 @@ var ts; case 102: return parseTypeQuery(); case 16: - return parseTypeLiteral(); + return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); case 20: return parseTupleType(); case 18: @@ -13090,16 +12879,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: @@ -13124,13 +12913,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) { @@ -13146,10 +12958,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) { @@ -13195,7 +13007,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); @@ -13212,14 +13024,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(); } @@ -13338,7 +13150,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191); + var node = createNode(195); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -13354,13 +13166,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(185, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181, identifier.pos); + node = createNode(185, 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); @@ -13494,7 +13306,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181); + var node = createNode(185); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -13526,7 +13338,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(189, leftOperand.pos); + var node = createNode(193, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -13539,7 +13351,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) { @@ -13617,39 +13429,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188, left.pos); + var node = createNode(192, 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(200, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186); + var node = createNode(190); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182); + var node = createNode(186); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183); + var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184); + var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -13664,7 +13476,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185); + var node = createNode(189); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -13680,7 +13492,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178) { + if (simpleUnaryExpression.kind === 182) { 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 { @@ -13733,7 +13545,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(186); + var node = createNode(190); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -13745,7 +13557,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(191, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -13768,7 +13580,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(173, expression.pos); + var node = createNode(177, 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); @@ -13790,8 +13602,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 === 248) { + var node = createNode(246, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -13801,14 +13613,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243); + ts.Debug.assert(opening.kind === 247); 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(192, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -13861,7 +13673,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(244, fullStart); + node = createNode(248, fullStart); scanJsxText(); } else { @@ -13873,7 +13685,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(243, fullStart); + node = createNode(247, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -13884,7 +13696,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(177, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13892,7 +13704,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248); + var node = createNode(252); parseExpected(16); if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); @@ -13911,7 +13723,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246); + var node = createNode(250); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -13926,7 +13738,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247); + var node = createNode(251); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -13934,7 +13746,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245); + var node = createNode(249); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -13947,7 +13759,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178); + var node = createNode(182); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -13958,7 +13770,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(177, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13966,13 +13778,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197, expression.pos); + var nonNullExpression = createNode(201, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(174, expression.pos); + var indexedAccess = createNode(178, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -13986,7 +13798,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(177, expression.pos); + var tagExpression = createNode(181, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -14005,7 +13817,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(179, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -14013,7 +13825,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(179, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14032,7 +13844,7 @@ var ts; if (!parseOptional(26)) { return undefined; } - var typeArguments = parseDelimitedList(18, parseType); + var typeArguments = parseDelimitedList(19, parseType); if (!parseExpected(28)) { return undefined; } @@ -14108,28 +13920,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179); + var node = createNode(183); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192); + var node = createNode(196); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(194) : + token() === 25 ? createNode(198) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171); + var node = createNode(175); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14140,15 +13952,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(259, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -14164,7 +13982,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254, fullStart); + var shorthandDeclaration = createNode(258, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14175,7 +13993,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253, fullStart); + var propertyAssignment = createNode(257, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14185,7 +14003,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172); + var node = createNode(176); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14199,7 +14017,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(180); + var node = createNode(184); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -14221,7 +14039,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176); + var node = createNode(180); parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -14231,7 +14049,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200); + var node = createNode(204); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14262,12 +14080,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202); + var node = createNode(206); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(204); + var node = createNode(208); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14277,7 +14095,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205); + var node = createNode(209); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14288,7 +14106,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206); + var node = createNode(210); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14311,21 +14129,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(208, pos); + var forInStatement = createNode(212, 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(213, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207, pos); + var forStatement = createNode(211, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14343,7 +14161,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 ? 71 : 76); + parseExpected(kind === 215 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14351,7 +14169,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212); + var node = createNode(216); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14360,7 +14178,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213); + var node = createNode(217); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14369,7 +14187,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249); + var node = createNode(253); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14377,7 +14195,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250); + var node = createNode(254); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14387,12 +14205,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214); + var node = createNode(218); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(228, scanner.getStartPos()); + var caseBlock = createNode(232, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14400,14 +14218,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(216); + var node = createNode(220); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(217); + var node = createNode(221); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14418,7 +14236,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252); + var result = createNode(256); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14428,7 +14246,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218); + var node = createNode(222); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14437,13 +14255,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(219, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203, fullStart); + var expressionStatement = createNode(207, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -14472,10 +14290,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: @@ -14483,13 +14301,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: @@ -14547,16 +14365,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(); @@ -14595,9 +14413,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(210); + return parseBreakOrContinueStatement(214); case 71: - return parseBreakOrContinueStatement(211); + return parseBreakOrContinueStatement(215); case 95: return parseReturnStatement(); case 106: @@ -14616,9 +14434,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: @@ -14629,8 +14447,8 @@ var ts; case 113: case 116: case 114: - case 129: - case 138: + case 130: + case 139: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -14653,13 +14471,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); @@ -14676,7 +14494,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -14697,16 +14515,17 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(194); + return createNode(198); } - var node = createNode(170); + var node = createNode(174); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170); + var node = createNode(174); + node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55) { @@ -14721,14 +14540,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168); + var node = createNode(172); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169); + var node = createNode(173); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -14747,7 +14566,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219); + var node = createNode(223); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -14756,7 +14575,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220); + var node = createNode(224); switch (token()) { case 103: break; @@ -14770,7 +14589,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -14785,7 +14604,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -14793,7 +14612,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -14806,7 +14625,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); @@ -14815,7 +14634,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; @@ -14828,7 +14647,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; @@ -14836,7 +14655,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)); } @@ -14869,7 +14688,7 @@ var ts; case 111: case 112: case 114: - case 129: + case 130: return true; default: return false; @@ -14898,7 +14717,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()) { @@ -14921,7 +14740,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) { @@ -14978,7 +14797,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(199); + var result = createNode(203); nextToken(); return finishNode(result); } @@ -15003,16 +14822,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, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -15041,13 +14860,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(255); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -15056,10 +14875,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195); + var node = createNode(199); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } @@ -15070,7 +14889,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -15081,10 +14900,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135); + parseExpected(136); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -15093,13 +14912,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(255, scanner.getStartPos()); + var node = createNode(260, 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(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15114,7 +14933,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(231, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15125,7 +14944,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226, fullStart); + var node = createNode(230, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15137,10 +14956,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138) { + if (token() === 139) { node.name = parseIdentifier(); node.flags |= 512; } @@ -15157,14 +14976,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); } @@ -15172,7 +14991,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 && + return token() === 131 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -15182,13 +15001,13 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229, fullStart); + var exportDeclaration = createNode(233, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); - parseExpected(127); + parseExpected(128); exportDeclaration.name = parseIdentifier(); - parseExpected(24); + parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { @@ -15197,8 +15016,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(234, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15208,27 +15027,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(231, fullStart); + var importDeclaration = createNode(235, 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(236, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); } return finishNode(importClause); } @@ -15238,8 +15057,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(241); - parseExpected(130); + var node = createNode(245); + parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); parseExpected(19); @@ -15256,7 +15075,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(233); + var namespaceImport = createNode(237); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15264,14 +15083,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 === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(243); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235); + return parseImportOrExportSpecifier(239); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15290,23 +15109,23 @@ var ts; else { node.name = identifierName; } - if (kind === 235 && checkIdentifierIsKeyword) { + if (kind === 239 && 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(241, 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(242); + if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -15314,7 +15133,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(240, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15393,50 +15212,14 @@ 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 === 234 && node.moduleReference.kind === 245 + || node.kind === 235 + || node.kind === 240 + || node.kind === 241 ? node : undefined; }); } - var ParsingContext; - (function (ParsingContext) { - ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; - 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"; - })(ParsingContext || (ParsingContext = {})); - var Tristate; - (function (Tristate) { - Tristate[Tristate["False"] = 0] = "False"; - Tristate[Tristate["True"] = 1] = "True"; - Tristate[Tristate["Unknown"] = 2] = "Unknown"; - })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -15457,8 +15240,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(); @@ -15468,7 +15251,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(257, scanner.getTokenPos()); + var result = createNode(262, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -15479,12 +15262,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(261, type.pos); + var unionType = createNode(266, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(268, type.pos); + var optionalType = createNode(273, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -15495,20 +15278,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(260, type.pos); + var arrayType = createNode(265, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(263, type.pos); + var nullableType = createNode(268, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(264, type.pos); + var nonNullableType = createNode(269, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -15542,14 +15325,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: @@ -15560,30 +15343,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271); + var result = createNode(276); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270); + var result = createNode(275); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269); + var result = createNode(274); nextToken(); parseExpected(18); - result.parameters = parseDelimitedList(22, parseJSDocParameter); + result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19); if (token() === 55) { @@ -15593,7 +15376,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); @@ -15601,7 +15384,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267); + var result = createNode(272); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -15621,7 +15404,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(23, parseJSDocType); + var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28); @@ -15635,26 +15418,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(270); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264); + var result = createNode(269); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262); + var result = createNode(267); nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); + result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21); return finishNode(result); @@ -15666,7 +15449,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261); + var result = createNode(266); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -15682,12 +15465,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258); + var result = createNode(263); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282); + var result = createNode(287); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -15700,17 +15483,17 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(259, pos); + var result = createNode(264, pos); return finishNode(result); } else { - var result = createNode(263, pos); + var result = createNode(268, 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; @@ -15732,12 +15515,6 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; - var JSDocState; - (function (JSDocState) { - JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; - JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; - JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; - })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -15770,6 +15547,7 @@ var ts; } if (token() === 4) { state = 0; + indent = 0; nextJSDocToken(); } while (token() !== 1) { @@ -15849,7 +15627,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(273, start); + var result = createNode(278, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -15956,7 +15734,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274, atToken.pos); + var result = createNode(279, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16011,7 +15789,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -16022,20 +15800,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 === 281; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276, atToken.pos); + var result = createNode(281, 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 === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -16050,7 +15828,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -16060,18 +15838,25 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279, atToken.pos); + var typedefTag = createNode(284, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; - typedefTag.name = parseJSDocIdentifierName(); + typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); + if (typedefTag.fullName) { + var rightNode = typedefTag.fullName; + while (rightNode.kind !== 70) { + rightNode = rightNode.body; + } + typedefTag.name = rightNode; + } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267) { + if (typeExpression.type.kind === 272) { 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(); } } @@ -16085,7 +15870,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(286, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16122,6 +15907,21 @@ var ts; scanner.setTextPos(resumePos); return finishNode(jsDocTypeLiteral); } + function parseJSDocTypeNameWithNamespace(flags) { + var pos = scanner.getTokenPos(); + var typeNameOrNamespaceName = parseJSDocIdentifierName(); + if (typeNameOrNamespaceName && parseOptional(22)) { + var jsDocNamespaceNode = createNode(230, pos); + jsDocNamespaceNode.flags |= flags; + jsDocNamespaceNode.name = typeNameOrNamespaceName; + jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); + return jsDocNamespaceNode; + } + if (typeNameOrNamespaceName && flags & 4) { + typeNameOrNamespaceName.isInJSDocNamespace = true; + } + return typeNameOrNamespaceName; + } } function tryParseChildTag(parentTag) { ts.Debug.assert(token() === 56); @@ -16142,29 +15942,32 @@ var ts; return true; case "prop": case "property": - if (!parentTag.jsDocPropertyTags) { - parentTag.jsDocPropertyTags = []; - } var propertyTag = parsePropertyTag(atToken, tagName); - parentTag.jsDocPropertyTags.push(propertyTag); - return true; + if (propertyTag) { + if (!parentTag.jsDocPropertyTags) { + parentTag.jsDocPropertyTags = []; + } + parentTag.jsDocPropertyTags.push(propertyTag); + return true; + } + return false; } 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 === 283; })) { 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) { @@ -16175,7 +15978,7 @@ var ts; break; } } - var result = createNode(278, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -16489,31 +16292,21 @@ var ts; } } } - var InvalidPosition; - (function (InvalidPosition) { - InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; - })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { - (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; function getModuleInstanceState(node) { - if (node.kind === 223 || node.kind === 224) { + if (node.kind === 227 || node.kind === 228) { 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 === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 227) { + else if (node.kind === 231) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -16529,27 +16322,18 @@ var ts; }); return state_1; } - else if (node.kind === 226) { + else if (node.kind === 230) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } + else if (node.kind === 70 && node.isInJSDocNamespace) { + return 0; + } else { return 1; } } ts.getModuleInstanceState = getModuleInstanceState; - var ContainerFlags; - (function (ContainerFlags) { - ContainerFlags[ContainerFlags["None"] = 0] = "None"; - ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; - ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; - ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; - ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; - ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; - ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; - ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; - ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; - })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -16647,7 +16431,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 === 230)) { symbol.valueDeclaration = node; } } @@ -16657,7 +16441,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; @@ -16668,21 +16452,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 241: return "__export"; - case 236: + case 240: return node.isExportEquals ? "export=" : "default"; - case 188: + case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -16694,20 +16478,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221: - case 222: + case 225: + case 226: return ts.hasModifier(node, 512) ? "default" : undefined; - case 269: + case 274: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143: - ts.Debug.assert(node.parent.kind === 269); + case 144: + ts.Debug.assert(node.parent.kind === 274); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279: + case 284: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 205) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -16751,7 +16535,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -16771,7 +16555,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 === 243 || (node.kind === 234 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -16779,7 +16563,11 @@ var ts; } } else { - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) { + var isJSDocTypedefInJSDocNamespace = node.kind === 284 && + node.name && + node.name.kind === 70 && + node.name.isInJSDocNamespace; + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793064 ? 2097152 : 0) | (symbolFlags & 1920 ? 4194304 : 0); @@ -16814,7 +16602,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(); } @@ -16830,13 +16618,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 === 261) { node.flags |= emitFlags; } if (isIIFE) { @@ -16871,6 +16659,7 @@ var ts; skipTransformFlagAggregation = true; bindChildrenWorker(node); skipTransformFlagAggregation = false; + subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); } else { var savedSubtreeTransformFlags = subtreeTransformFlags; @@ -16888,64 +16677,64 @@ var ts; return; } switch (node.kind) { - case 206: + case 210: bindWhileStatement(node); break; - case 205: + case 209: bindDoStatement(node); break; - case 207: + case 211: bindForStatement(node); break; - case 208: - case 209: + case 212: + case 213: bindForInOrForOfStatement(node); break; - case 204: + case 208: bindIfStatement(node); break; - case 212: case 216: + case 220: bindReturnOrThrow(node); break; - case 211: - case 210: + case 215: + case 214: bindBreakOrContinueStatement(node); break; - case 217: + case 221: bindTryStatement(node); break; - case 214: + case 218: bindSwitchStatement(node); break; - case 228: + case 232: bindCaseBlock(node); break; - case 249: + case 253: bindCaseClause(node); break; - case 215: + case 219: bindLabeledStatement(node); break; - case 186: + case 190: bindPrefixUnaryExpressionFlow(node); break; - case 187: + case 191: bindPostfixUnaryExpressionFlow(node); break; - case 188: + case 192: bindBinaryExpressionFlow(node); break; - case 182: + case 186: bindDeleteExpressionFlow(node); break; - case 189: + case 193: bindConditionalExpressionFlow(node); break; - case 219: + case 223: bindVariableDeclarationFlow(node); break; - case 175: + case 179: bindCallExpressionFlow(node); break; default: @@ -16957,15 +16746,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 177: return isNarrowableReference(expr); - case 175: - return hasNarrowableArgument(expr); case 179: + return hasNarrowableArgument(expr); + case 183: return isNarrowingExpression(expr.expression); - case 188: + case 192: return isNarrowingBinaryExpression(expr); - case 186: + case 190: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -16973,7 +16762,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 173 && isNarrowableReference(expr.expression); + expr.kind === 177 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -16984,14 +16773,14 @@ var ts; } } } - if (expr.expression.kind === 173 && + if (expr.expression.kind === 177 && 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 === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -17012,9 +16801,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179: + case 183: return isNarrowableOperand(expr.expression); - case 188: + case 192: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -17108,33 +16897,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204: - case 206: - case 205: + case 208: + case 210: + case 209: return parent.expression === node; - case 207: - case 189: + case 211: + case 193: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179) { + if (node.kind === 183) { node = node.expression; } - else if (node.kind === 186 && node.operator === 50) { + else if (node.kind === 190 && node.operator === 50) { node = node.operand; } else { - return node.kind === 188 && (node.operatorToken.kind === 52 || + return node.kind === 192 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 || - node.parent.kind === 186 && + while (node.parent.kind === 183 || + node.parent.kind === 190 && node.parent.operator === 50) { node = node.parent; } @@ -17176,8 +16965,11 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 219 + ? 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); @@ -17208,7 +17000,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220) { + if (node.initializer.kind !== 224) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17230,7 +17022,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212) { + if (node.kind === 216) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17250,7 +17042,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 ? breakTarget : continueTarget; + var flowLabel = node.kind === 215 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17307,7 +17099,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 === 254; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17368,11 +17160,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 !== 209) { + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 && node.operatorToken.kind === 57) { + if (node.kind === 192 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -17383,10 +17177,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171) { + else if (node.kind === 175) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192) { + if (e.kind === 196) { bindAssignmentTargetFlow(e.expression); } else { @@ -17394,15 +17188,18 @@ var ts; } } } - else if (node.kind === 172) { + else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253) { + if (p.kind === 257) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254) { + else if (p.kind === 258) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 259) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -17454,9 +17251,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 === 178) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17467,7 +17264,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173) { + if (node.expression.kind === 177) { bindAssignmentTargetFlow(node.expression); } } @@ -17477,9 +17274,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); @@ -17498,16 +17297,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 === 212 || node.parent.parent.kind === 213) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 179) { + while (expr.kind === 183) { expr = expr.expression; } - if (expr.kind === 180 || expr.kind === 181) { + if (expr.kind === 184 || expr.kind === 185) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -17515,7 +17314,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173) { + if (node.expression.kind === 177) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17524,51 +17323,52 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193: - case 222: - case 225: - case 172: - case 160: - case 281: - case 265: - return 1; - case 223: - return 1 | 64; - case 269: + case 197: case 226: - case 224: + case 229: + case 176: + case 161: + case 286: + case 270: + return 1; + case 227: + return 1 | 64; + case 274: + case 230: + case 228: + case 170: return 1 | 32; - case 256: + case 261: 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 225: + 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 184: + case 185: return 1 | 4 | 32 | 8 | 16; - case 227: + case 231: return 4; - case 146: + case 147: return node.initializer ? 4 : 0; - case 252: - case 207: - case 208: - case 209: - case 228: + case 256: + case 211: + case 212: + case 213: + case 232: return 2; - case 200: + case 204: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -17584,36 +17384,37 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 226: + case 230: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256: + case 261: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193: - case 222: + case 197: + case 226: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225: + case 229: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160: - case 172: - case 223: - case 265: - case 281: + case 161: + case 176: + case 227: + case 270: + case 286: 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 224: + case 152: + case 225: + case 184: + case 185: + case 274: + case 228: + case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -17628,11 +17429,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 === 261 ? node : node.body; + if (body && (body.kind === 261 || body.kind === 231)) { 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 === 241 || stat.kind === 240) { return true; } } @@ -17704,20 +17505,15 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); if (inStrictMode) { 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 === 259 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 + var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -17739,10 +17535,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226: + case 230: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256: + case 261: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -17832,8 +17628,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 226 && + if (blockScopeContainer.kind !== 261 && + blockScopeContainer.kind !== 230 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -17876,7 +17672,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); @@ -17914,17 +17710,25 @@ var ts; function bindWorker(node) { switch (node.kind) { case 70: + if (node.isInJSDocNamespace) { + var parentNode = node.parent; + while (parentNode && parentNode.kind !== 284) { + 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 === 258)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173: + case 177: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188: + case 192: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -17947,111 +17751,132 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252: + case 256: return checkStrictModeCatchClause(node); - case 182: + case 186: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 187: + case 191: return checkStrictModePostfixUnaryExpression(node); - case 186: + case 190: return checkStrictModePrefixUnaryExpression(node); - case 213: + case 217: 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 223: + case 174: + if (node.dotDotDotToken && node.parent.kind === 172) { + emitFlags |= 32768; + } return bindVariableDeclarationOrBindingElement(node); + case 147: case 146: - case 145: - case 266: + case 271: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 280: + case 285: return bindJSDocProperty(node); - case 253: - case 254: + case 257: + case 258: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 255: + case 260: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 247: - emitFlags |= 16384; + case 259: + case 251: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 176 && + root.parent.kind === 192 && + 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 225: + 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 274: return bindFunctionOrConstructorType(node); - case 160: - case 281: - case 265: + case 161: + case 170: + case 286: + case 270: return bindAnonymousDeclaration(node, 2048, "__type"); - case 172: + case 176: return bindObjectLiteralExpression(node); - case 180: - case 181: + case 184: + case 185: return bindFunctionExpression(node); - case 175: + case 179: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 193: - case 222: + case 197: + case 226: inStrictMode = true; return bindClassLikeDeclaration(node); - case 223: + case 227: return bindBlockScopedDeclaration(node, 64, 792968); - case 279: - case 224: + case 284: + if (!node.fullName || node.fullName.kind === 70) { + return bindBlockScopedDeclaration(node, 524288, 793064); + } + break; + case 228: return bindBlockScopedDeclaration(node, 524288, 793064); - case 225: - 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); + return bindEnumDeclaration(node); + case 230: + return bindModuleDeclaration(node); + case 234: case 237: - return bindExportDeclaration(node); + case 239: + case 243: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 233: + return bindNamespaceExportDeclaration(node); case 236: + return bindImportClause(node); + case 241: + return bindExportDeclaration(node); + case 240: return bindExportAssignment(node); - case 256: + case 261: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200: + case 204: if (!ts.isFunctionLike(node.parent)) { return; } - case 227: + case 231: return updateStrictModeStatementList(node.statements); } } @@ -18060,7 +17885,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166) { + if (parameterName && parameterName.kind === 167) { seenThisKeyword = true; } bind(type); @@ -18079,7 +17904,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18089,17 +17914,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 !== 261) { 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; } @@ -18138,11 +17963,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 221 || container.kind === 180) { + if (container.kind === 225 || container.kind === 184) { 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); @@ -18182,7 +18007,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 222) { + if (node.kind === 226) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -18300,15 +18125,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 !== 206) || + node.kind === 226 || + (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 || + (node.kind !== 205 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18322,54 +18147,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175: - return computeCallExpression(node, subtreeFlags); - case 176: - return computeNewExpression(node, subtreeFlags); - case 226: - return computeModuleDeclaration(node, subtreeFlags); case 179: - return computeParenthesizedExpression(node, subtreeFlags); - case 188: - return computeBinaryExpression(node, subtreeFlags); - case 203: - return computeExpressionStatement(node, subtreeFlags); - case 143: - return computeParameter(node, subtreeFlags); - case 181: - return computeArrowFunction(node, subtreeFlags); + return computeCallExpression(node, subtreeFlags); case 180: - return computeFunctionExpression(node, subtreeFlags); - case 221: - 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 computeClassDeclaration(node, subtreeFlags); - case 193: - return computeClassExpression(node, subtreeFlags); - case 251: - return computeHeritageClause(node, subtreeFlags); - case 195: - return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149: - return computeConstructor(node, subtreeFlags); - case 146: - return computePropertyDeclaration(node, subtreeFlags); - case 148: - return computeMethod(node, subtreeFlags); - case 150: - case 151: - return computeAccessor(node, subtreeFlags); + return computeNewExpression(node, subtreeFlags); case 230: + return computeModuleDeclaration(node, subtreeFlags); + case 183: + return computeParenthesizedExpression(node, subtreeFlags); + case 192: + return computeBinaryExpression(node, subtreeFlags); + case 207: + return computeExpressionStatement(node, subtreeFlags); + case 144: + return computeParameter(node, subtreeFlags); + case 185: + return computeArrowFunction(node, subtreeFlags); + case 184: + return computeFunctionExpression(node, subtreeFlags); + case 225: + return computeFunctionDeclaration(node, subtreeFlags); + case 223: + return computeVariableDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclarationList(node, subtreeFlags); + case 205: + return computeVariableStatement(node, subtreeFlags); + case 219: + return computeLabeledStatement(node, subtreeFlags); + case 226: + return computeClassDeclaration(node, subtreeFlags); + case 197: + return computeClassExpression(node, subtreeFlags); + case 255: + return computeHeritageClause(node, subtreeFlags); + case 256: + return computeCatchClause(node, subtreeFlags); + case 199: + return computeExpressionWithTypeArguments(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 234: return computeImportEquals(node, subtreeFlags); - case 173: + case 177: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -18383,19 +18210,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 177: + case 178: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -18407,27 +18234,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 === 176) { + transformFlags |= 48 | 3072 | 49152; + } + else if (operatorTokenKind === 57 && leftKind === 175) { + 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; @@ -18437,33 +18265,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 === 200 + || expressionKind === 182) { 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; @@ -18472,36 +18303,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; @@ -18511,15 +18341,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 |= 3072; + } + node.transformFlags = transformFlags | 536870912; + 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; @@ -18528,10 +18366,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 @@ -18540,13 +18378,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; @@ -18557,15 +18395,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; @@ -18575,27 +18413,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; @@ -18605,54 +18443,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 === 172) { + transformFlags |= 48 | 3072 | 67108864; + } + else if (nameKind === 173) { + transformFlags |= 3072 | 67108864; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -18663,24 +18510,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; @@ -18688,15 +18532,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; @@ -18705,26 +18549,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 189: + transformFlags |= 192; break; case 113: case 111: @@ -18732,52 +18576,49 @@ var ts; case 116: case 123: case 75: - case 225: - case 255: - case 178: - case 196: - case 197: - case 129: + case 229: + case 260: + case 182: + case 200: + case 201: + case 130: transformFlags |= 3; break; - case 242: - case 243: - case 244: - case 10: - case 245: case 246: case 247: case 248: + case 10: + case 249: + case 250: + case 251: + case 252: transformFlags |= 12; break; - case 83: - transformFlags |= 768 | 3; - break; - case 78: + case 213: + transformFlags |= 48; case 12: case 13: case 14: case 15: - case 190: - case 177: - case 254: - case 209: - transformFlags |= 768; + case 194: + case 181: + case 258: + case 114: + transformFlags |= 3072; break; - case 191: - transformFlags |= 768 | 16777216; + case 195: + 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: @@ -18791,73 +18632,142 @@ var ts; case 163: case 164: case 165: - case 223: - case 224: case 166: + case 227: + case 228: case 167: + case 168: + case 169: + case 170: + case 171: 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 196: + case 259: + transformFlags |= 8388608; break; + case 174: + 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; + transformFlags |= 262144; break; case 172: - excludeFlags = 539110741; - if (subtreeFlags & 2097152) { - transformFlags |= 768; + case 173: + if (subtreeFlags & 8388608) { + transformFlags |= 48 | 67108864; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + else { + transformFlags |= 3072 | 67108864; } break; - case 171: + case 145: + transformFlags |= 3 | 65536; + break; case 176: - excludeFlags = 537922901; + excludeFlags = 554784085; + if (subtreeFlags & 16777216) { + transformFlags |= 3072; + } if (subtreeFlags & 1048576) { - transformFlags |= 768; + transformFlags |= 262144; + } + if (subtreeFlags & 8388608) { + transformFlags |= 48; } break; - case 205: - case 206: - case 207: - case 208: - if (subtreeFlags & 4194304) { - transformFlags |= 768; + case 175: + case 180: + excludeFlags = 545281365; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } break; - case 256: - if (subtreeFlags & 65536) { - transformFlags |= 768; - } - break; - case 212: + case 209: case 210: case 211: - transformFlags |= 33554432; + case 212: + if (subtreeFlags & 33554432) { + transformFlags |= 3072; + } + break; + case 261: + if (subtreeFlags & 524288) { + transformFlags |= 3072; + } + break; + case 216: + case 214: + case 215: + transformFlags |= 268435456; break; } node.transformFlags = transformFlags | 536870912; return transformFlags & ~excludeFlags; } + function getTransformFlagsSubtreeExclusions(kind) { + if (kind >= 156 && kind <= 171) { + return -3; + } + switch (kind) { + case 179: + case 180: + case 175: + return 545281365; + case 230: + return 839734613; + case 144: + return 604001621; + case 185: + return 979719509; + case 184: + case 225: + return 980243797; + case 224: + return 604001621; + case 226: + case 197: + return 559895893; + case 150: + return 975983957; + case 149: + case 151: + 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 155: + case 227: + case 228: + return -3; + case 176: + return 554784085; + default: + return 536892757; + } + } + ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; })(ts || (ts = {})); var ts; (function (ts) { @@ -18869,24 +18779,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) { @@ -18895,18 +18831,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 { @@ -18917,7 +18841,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -18929,7 +18852,9 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } } ts.getEffectiveTypeRoots = getEffectiveTypeRoots; function getDefaultTypeRoots(currentDirectory, host) { @@ -18937,17 +18862,12 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_7 = ts.getDirectoryPath(currentDirectory); - if (parent_7 === currentDirectory) { - break; - } - currentDirectory = parent_7; - } + }); return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); @@ -18956,7 +18876,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -18979,62 +18898,57 @@ var ts; } } var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_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) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = 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); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + function secondaryLookup() { + var resolvedFile; + 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); } - else { + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getAutomaticTypeDirectiveNames(options, host) { @@ -19101,15 +19015,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; } @@ -19143,7 +19057,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; } @@ -19160,7 +19074,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; } @@ -19171,7 +19085,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; } @@ -19186,77 +19100,87 @@ var ts; matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); 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 tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, false, state); + return path_1 && { path: path_1, extension: tsExtension }; } - } - return undefined; + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); } else { var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); 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, 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); + return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, 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 realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + 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; } @@ -19266,21 +19190,30 @@ 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) { + function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); @@ -19291,29 +19224,32 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } - failedLookupLocation.push(fileName); + failedLookupLocations.push(fileName); return undefined; } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); if (directoryExists && state.host.fileExists(packageJsonPath)) { 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, failedLookupLocations, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, 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); } } } @@ -19321,95 +19257,96 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } - failedLookupLocation.push(packageJsonPath); + failedLookupLocations.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !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) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); } - function loadModuleFromNodeModulesWorker(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; - } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; - } - directory = parentPath; + }); + } + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== 1) { + return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); } - return undefined; } 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 = forEachAncestorDirectory(containingDirectory, function (directory) { + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, 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 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 = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function forEachAncestorDirectory(directory, callback) { while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - return referencedSourceFile; + var result = callback(directory); + if (result !== undefined) { + return result; } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { return undefined; } - containingDirectory = parentPath; + directory = parentPath; } } })(ts || (ts = {})); @@ -19499,7 +19436,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(); @@ -19513,9 +19453,9 @@ var ts; var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 33554432, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 2097152, "undefined"); var nullType = createIntrinsicType(4096, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 33554432, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 2097152, "null"); var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var trueType = createIntrinsicType(128, "true"); @@ -19525,11 +19465,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 |= 134217728; + 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); @@ -19591,66 +19535,6 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; - TypeFacts[TypeFacts["All"] = 8388607] = "All"; - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -19677,6 +19561,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", @@ -19693,17 +19579,25 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); 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; @@ -19784,7 +19678,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { + (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -19840,7 +19734,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; } @@ -19877,8 +19771,11 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } + function getObjectFlags(type) { + return type.flags & 32768 ? type.objectFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 256 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -19915,36 +19812,39 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } + if (isUsedInFunctionOrNonStaticProperty(usage)) { + return true; + } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 219 || + return declaration.kind !== 223 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } - return isUsedInFunctionOrNonStaticProperty(declaration, usage); + var container = ts.getEnclosingBlockScopeContainer(declaration); + return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201: - case 207: - case 209: + case 205: + case 211: + case 213: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 208: - case 209: + case 212: + case 213: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); + function isUsedInFunctionOrNonStaticProperty(usage, container) { var current = usage; while (current) { if (current === container) { @@ -19954,7 +19854,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) { @@ -19977,18 +19877,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 !== 278) { 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) { @@ -20000,13 +19900,13 @@ var ts; } } switch (location.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226: + case 230: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 || ts.isAmbientModule(location)) { + if (location.kind === 261 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20016,7 +19916,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 239)) { + ts.getDeclarationOfKind(moduleExports[name], 243)) { break; } } @@ -20024,13 +19924,13 @@ var ts; break loop; } break; - case 225: + case 229: 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) { @@ -20040,9 +19940,9 @@ var ts; } } break; - case 222: - case 193: - case 223: + case 226: + case 197: + case 227: 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); @@ -20050,7 +19950,7 @@ var ts; } break loop; } - if (location.kind === 193 && meaning & 32) { + if (location.kind === 197 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20058,28 +19958,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 === 227) { 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 225: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180: + case 184: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20092,8 +19992,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)) { @@ -20135,7 +20035,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 === 233) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20182,9 +20082,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 173: + case 177: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195: + case 199: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20205,7 +20105,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, 223), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20222,10 +20122,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230) { + if (node.kind === 234) { return node; } - while (node && node.kind !== 231) { + while (node && node.kind !== 235) { node = node.parent; } return node; @@ -20235,7 +20135,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 === 245) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20296,28 +20196,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; } @@ -20339,19 +20239,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230: + case 234: return getTargetOfImportEqualsDeclaration(node); - case 232: - return getTargetOfImportClause(node); - case 233: - return getTargetOfNamespaceImport(node); - case 235: - return getTargetOfImportSpecifier(node); - case 239: - return getTargetOfExportSpecifier(node); case 236: + return getTargetOfImportClause(node); + case 237: + return getTargetOfNamespaceImport(node); + case 239: + return getTargetOfImportSpecifier(node); + case 243: + return getTargetOfExportSpecifier(node); + case 240: return getTargetOfExportAssignment(node); - case 229: + case 233: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20395,10 +20295,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236) { + if (node.kind === 240) { checkExpressionCached(node.expression); } - else if (node.kind === 239) { + else if (node.kind === 243) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20410,11 +20310,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 === 234); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20433,9 +20333,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 === 177) { + 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; @@ -20460,27 +20360,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); @@ -20496,14 +20397,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; @@ -20618,7 +20535,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; } } @@ -20640,8 +20557,9 @@ var ts; type.intrinsicName = "boolean"; return type; } - function createObjectType(kind, symbol) { - var type = createType(kind); + function createObjectType(objectFlags, symbol) { + var type = createType(32768); + type.objectFlags = objectFlags; type.symbol = symbol; return type; } @@ -20665,7 +20583,7 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; @@ -20677,7 +20595,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - return setObjectTypeMembers(createObjectType(2097152, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -20688,11 +20606,11 @@ var ts; } } switch (location_1.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226: + case 230: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -20725,7 +20643,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -20756,7 +20674,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, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -20770,10 +20688,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; @@ -20829,7 +20747,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -20863,11 +20781,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 === 177 || + entityName.parent.kind === 234) { meaning = 1920; } else { @@ -20959,10 +20877,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 === 228) { return getSymbolOfNode(node); } } @@ -20970,7 +20888,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 && + node.parent.kind === 231 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -20984,10 +20902,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193: + case 197: return "(Anonymous class)"; - case 180: - case 181: + case 184: + case 185: return "(Anonymous function)"; } } @@ -21039,9 +20957,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_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21082,7 +21000,7 @@ var ts; } writer.writeKeyword("this"); } - else if (type.flags & 131072) { + else if (getObjectFlags(type) & 4) { writeTypeReference(type, nextFlags); } else if (type.flags & 256) { @@ -21090,23 +21008,34 @@ var ts; writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } - else if (type.flags & (32768 | 65536 | 16 | 16384)) { + else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && ((type.flags & 2097152 && !type.target) || type.flags & 1572864) && type.aliasSymbol && + else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } - else if (type.flags & 1572864) { + else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); } - else if (type.flags & 2097152) { + else if (getObjectFlags(type) & (16 | 32)) { writeAnonymousType(type, nextFlags); } 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); @@ -21151,7 +21080,7 @@ var ts; writePunctuation(writer, 20); writePunctuation(writer, 21); } - else if (type.target.flags & 262144) { + else if (type.target.objectFlags & 8) { writePunctuation(writer, 20); writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); writePunctuation(writer, 21); @@ -21163,12 +21092,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21181,7 +21110,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 18); } - if (type.flags & 524288) { + if (type.flags & 65536) { writeTypeList(formatUnionTypes(type.types), 48); } else { @@ -21227,7 +21156,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 === 261 || declaration.parent.kind === 231; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21243,7 +21172,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } writePunctuation(writer, 20); @@ -21261,7 +21190,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -21281,6 +21210,12 @@ var ts; return false; } function writeLiteralType(type, flags) { + if (type.objectFlags & 32) { + if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { + writeMappedType(type); + return; + } + } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { @@ -21317,6 +21252,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); @@ -21329,8 +21270,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); @@ -21353,9 +21294,32 @@ var ts; writer.writeLine(); } } + } + function writeMappedType(type) { + writePunctuation(writer, 16); + writer.writeLine(); + writer.increaseIndent(); + if (type.declaration.readonlyToken) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); + writeSpace(writer); + writeKeyword(writer, 91); + writeSpace(writer); + writeType(getConstraintTypeFromMappedType(type), 0); + writePunctuation(writer, 21); + if (type.declaration.questionToken) { + writePunctuation(writer, 54); + } + writePunctuation(writer, 55); + writeSpace(writer); + writeType(getTemplateTypeFromMappedType(type), 0); + writePunctuation(writer, 24); + writer.writeLine(); writer.decreaseIndent(); writePunctuation(writer, 17); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -21393,12 +21357,12 @@ var ts; buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 172) { 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 === 173) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -21412,7 +21376,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170); + ts.Debug.assert(bindingElement.kind === 174); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55); @@ -21540,63 +21504,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170: + case 174: return isDeclarationVisible(node.parent.parent); - case 219: + case 223: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 226: - case 222: - case 223: - case 224: - case 221: - case 225: case 230: + case 226: + case 227: + case 228: + case 225: + case 229: + case 234: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 234 && parent_8.kind !== 261 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_10); - case 146: - case 145: - case 150: - case 151: - case 148: + return isDeclarationVisible(parent_8); 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 231: 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 237: + case 239: + return false; + case 143: + case 261: + case 233: + return true; + case 240: return false; default: return false; @@ -21605,10 +21569,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236) { + if (node.parent && node.parent.kind === 240) { 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 === 243) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -21670,7 +21634,6 @@ var ts; return getSymbolLinks(target).declaredType; } if (propertyName === 1) { - ts.Debug.assert(!!(target.flags & 32768)); return target.resolvedBaseConstructorType; } if (propertyName === 3) { @@ -21687,12 +21650,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219: - case 220: - case 235: - case 234: - case 233: - case 232: + case 223: + case 224: + case 239: + case 238: + case 237: + case 236: node = node.parent; break; default: @@ -21718,22 +21681,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; @@ -21748,26 +21719,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 === 172) { + 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 !== 198 && !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) @@ -21782,9 +21772,6 @@ var ts; return unknownType; } } - else { - type = createArrayType(elementType); - } } if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) { type = getTypeWithFacts(type, 131072); @@ -21804,15 +21791,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 === 223 && + declaration.parent.kind === 224 && + declaration.parent.parent.kind === 205) { 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; @@ -21826,22 +21813,22 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 && expr.elements.length === 0; + return expr.kind === 175 && 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 === 212) { return stringType; } - if (declaration.parent.parent.kind === 209) { + if (declaration.parent.parent.kind === 213) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -21850,7 +21837,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 === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -21859,10 +21846,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); @@ -21888,7 +21875,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 254) { + if (declaration.kind === 258) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -21913,11 +21900,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); @@ -21929,7 +21916,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= 512; } return result; } @@ -21948,7 +21935,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 + return pattern.kind === 172 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -21958,7 +21945,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 253) { + if (declaration.kind === 257) { return type; } return getWidenedType(type); @@ -21973,7 +21960,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) { @@ -21983,28 +21970,28 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 252) { + if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 236) { + if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 285 && 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 === 192 || + declaration.kind === 177 && declaration.parent.kind === 192) { + 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 === 192 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22030,7 +22017,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150) { + if (accessor.kind === 151) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22050,9 +22037,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; @@ -22092,7 +22079,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)); } } @@ -22103,11 +22090,11 @@ 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 { - var type = createObjectType(2097152, symbol); + var type = createObjectType(16, symbol); links.type = strictNullChecks && symbol.flags & 536870912 ? includeFalsyTypes(type, 2048) : type; } @@ -22160,7 +22147,7 @@ var ts; return unknownType; } function getTargetType(type) { - return type.flags & 131072 ? type.target : type; + return getObjectFlags(type) & 4 ? type.target : type; } function hasBaseType(type, checkBase) { return check(type); @@ -22188,9 +22175,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 === 226 || node.kind === 197 || + node.kind === 225 || node.kind === 184 || + node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22199,15 +22186,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, 227); 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 === 227 || node.kind === 226 || + node.kind === 197 || node.kind === 228) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22220,7 +22207,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 2588672 && getSignaturesOfType(type, 1).length > 0; + return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -22232,7 +22219,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; @@ -22247,7 +22234,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 2588672) { + if (baseConstructorType.flags & 32768) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -22264,7 +22251,7 @@ var ts; } function getBaseTypes(type) { if (!type.resolvedBaseTypes) { - if (type.flags & 262144) { + if (type.objectFlags & 8) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } else if (type.symbol.flags & (32 | 64)) { @@ -22284,7 +22271,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 2588672)) { + if (!(baseConstructorType.flags & 32768)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -22305,7 +22292,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getTargetType(baseType).flags & (32768 | 65536))) { + if (!(getObjectFlags(getTargetType(baseType)) & 3)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -22333,12 +22320,12 @@ 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 === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (32768 | 65536)) { + if (getObjectFlags(getTargetType(baseType)) & 3) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -22362,7 +22349,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 === 227) { if (declaration.flags & 64) { return false; } @@ -22385,12 +22372,12 @@ var ts; function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var kind = symbol.flags & 32 ? 32768 : 65536; + var kind = symbol.flags & 32 ? 1 : 2; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters || kind === 32768 || !isIndependentInterface(symbol)) { - type.flags |= 131072; + if (outerTypeParameters || localTypeParameters || kind === 1 || !isIndependentInterface(symbol)) { + type.objectFlags |= 4; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -22412,8 +22399,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279); + var declaration = ts.getDeclarationOfKind(symbol, 284); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22424,14 +22410,15 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224); - type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); + declaration = ts.getDeclarationOfKind(symbol, 228); + type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { - links.typeParameters = typeParameters; + var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { + links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(links.typeParameters)] = type; + links.instantiations[getTypeListId(typeParameters)] = type; } } else { @@ -22448,14 +22435,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 190 && 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 === 229) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22483,7 +22470,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 === 229) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22498,7 +22485,7 @@ var ts; } enumType.memberTypes = memberTypes; if (memberTypeList.length > 1) { - enumType.flags |= 524288; + enumType.flags |= 65536; enumType.types = memberTypeList; unionTypes[getTypeListId(memberTypeList)] = enumType; } @@ -22510,7 +22497,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - links.declaredType = enumType.flags & 524288 ? + links.declaredType = enumType.flags & 65536 ? enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : enumType; } @@ -22521,7 +22508,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; @@ -22571,19 +22558,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 171: return true; - case 161: + case 162: return isIndependentType(node.elementType); - case 156: + case 157: return isIndependentTypeReference(node); } return false; @@ -22592,7 +22579,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++) { @@ -22608,12 +22595,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); } } @@ -22656,7 +22643,7 @@ var ts; return type; } function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 131072) { + if (getObjectFlags(type) & 4) { return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); } return type; @@ -22679,8 +22666,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); } @@ -22700,7 +22687,7 @@ var ts; numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -22735,14 +22722,14 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNodeNoAlias); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { 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); @@ -22827,7 +22814,7 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1); var stringIndexInfo = getUnionIndexInfo(type.types, 0); var numberIndexInfo = getUnionIndexInfo(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); @@ -22835,6 +22822,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; @@ -22847,17 +22837,17 @@ var ts; stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { 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); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { var members = symbol.members; @@ -22865,7 +22855,7 @@ var ts; var constructSignatures = getSignaturesOfSymbol(members["__new"]); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { var members = emptySymbols; @@ -22880,46 +22870,106 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 2588672) { + if (baseConstructorType.flags & 32768) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } } } + function resolveMappedTypeMembers(type) { + var members = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + var typeParameter = getTypeParameterFromMappedType(type); + var constraintType = getConstraintTypeFromMappedType(type); + var templateType = getTemplateTypeFromMappedType(type); + var isReadonly = !!type.declaration.readonlyToken; + var isOptional = !!type.declaration.questionToken; + var keyType = constraintType.flags & 16384 ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 262144 ? getIndexType(getApparentType(keyType.type)) : keyType; + forEachType(iterationType, function (t) { + var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; + var propType = instantiateType(templateType, templateMapper); + if (t.flags & (32 | 64 | 256)) { + var propName = t.text; + var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + prop.type = addOptionality(propType, isOptional); + prop.isReadonly = isReadonly; + members[propName] = prop; + } + else if (t.flags & 2) { + stringIndexInfo = createIndexInfo(propType, isReadonly); + } + else if (t.flags & 4) { + numberIndexInfo = createIndexInfo(propType, isReadonly); + } + }); + if (stringIndexInfo && numberIndexInfo && isTypeIdenticalTo(stringIndexInfo.type, numberIndexInfo.type)) { + numberIndexInfo = undefined; + } + setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } + function getTypeParameterFromMappedType(type) { + return type.typeParameter || + (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter))); + } + function getConstraintTypeFromMappedType(type) { + return type.constraintType || + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + } + function getTemplateTypeFromMappedType(type) { + return type.templateType || + (type.templateType = type.declaration.type ? + instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + unknownType); + } + function isGenericMappedType(type) { + if (getObjectFlags(type) & 32) { + var constraintType = getConstraintTypeFromMappedType(type); + return !!(constraintType.flags & (16384 | 262144)); + } + return false; + } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072) { - resolveTypeReferenceMembers(type); + if (type.flags & 32768) { + if (type.objectFlags & 4) { + resolveTypeReferenceMembers(type); + } + else if (type.objectFlags & 3) { + resolveClassOrInterfaceMembers(type); + } + else if (type.objectFlags & 16) { + resolveAnonymousTypeMembers(type); + } + else if (type.objectFlags & 32) { + resolveMappedTypeMembers(type); + } } - else if (type.flags & (32768 | 65536)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 2097152) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 524288) { + else if (type.flags & 65536) { resolveUnionTypeMembers(type); } - else if (type.flags & 1048576) { + else if (type.flags & 131072) { resolveIntersectionTypeMembers(type); } } return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { return resolveStructuredTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -22934,7 +22984,7 @@ var ts; var prop = _c[_b]; getUnionOrIntersectionProperty(type, prop.name); } - if (type.flags & 524288) { + if (type.flags & 65536) { break; } } @@ -22953,7 +23003,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 1572864 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { @@ -22966,27 +23018,18 @@ 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; var props; - var commonFlags = (containingType.flags & 1048576) ? 536870912 : 0; + var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; var isReadonly = false; var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { @@ -23006,7 +23049,7 @@ var ts; isReadonly = true; } } - else if (containingType.flags & 524288) { + else if (containingType.flags & 65536) { isPartial = true; } } @@ -23041,7 +23084,7 @@ var ts; result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; - result.type = containingType.flags & 524288 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { @@ -23061,7 +23104,7 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -23075,13 +23118,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 1572864) { + if (type.flags & 196608) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 4161536) { + if (type.flags & 229376) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -23091,7 +23134,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 4161536) { + if (type.flags & 229376) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -23122,7 +23165,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); @@ -23150,8 +23193,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 === 273) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -23160,11 +23203,18 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268; + return paramTag.typeExpression.type.kind === 273; } } } } + 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; @@ -23218,7 +23268,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167) { + if (param.type && param.type.kind === 171) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23230,10 +23280,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); @@ -23245,14 +23295,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); @@ -23269,14 +23319,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)) { @@ -23290,20 +23340,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 225: 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 184: + case 185: + case 274: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23364,13 +23414,18 @@ var ts; function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 131072 && type.target === globalArrayType) { + if (getObjectFlags(type) & 4 && type.target === globalArrayType) { return type.typeArguments[0]; } } 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) { @@ -23383,8 +23438,8 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; - var type = createObjectType(2097152); + var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -23397,7 +23452,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++) { @@ -23424,7 +23479,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; @@ -23457,7 +23512,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 = ""; @@ -23490,22 +23545,23 @@ var ts; result |= type.flags; } } - return result & 234881024; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var propagatedFlags = typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; - var flags = 131072 | propagatedFlags; - type = target.instantiations[id] = createObjectType(flags, target.symbol); + type = target.instantiations[id] = createObjectType(4, target.symbol); + type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; } return type; } function cloneTypeReference(source) { - var type = createObjectType(source.flags, source.symbol); + var type = createType(source.flags); + type.symbol = source.symbol; + type.objectFlags = source.objectFlags; type.target = source.target; type.typeArguments = source.typeArguments; return type; @@ -23521,7 +23577,7 @@ var ts; error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias))); + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -23529,18 +23585,23 @@ var ts; } return type; } - function getTypeFromTypeAliasReference(node, symbol) { + function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); return unknownType; } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + return getTypeAliasInstantiation(symbol, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); @@ -23557,11 +23618,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156: + case 157: return node.typeName; - case 267: + case 272: return node.name; - case 195: + case 199: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23585,7 +23646,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 267) { + if (symbol.flags & 107455 && node.kind === 272) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -23595,13 +23656,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267) { + if (node.kind === 272) { 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 @@ -23630,9 +23691,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 227: + case 229: return declaration; } } @@ -23641,7 +23702,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 2588672)) { + if (!(type.flags & 32768)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -23704,7 +23765,7 @@ var ts; property.type = typeParameter; properties.push(property); } - var type = createObjectType(262144 | 131072); + var type = createObjectType(8 | 4); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -23731,7 +23792,7 @@ var ts; function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNodeNoAlias)); + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); } return links.resolvedType; } @@ -23759,7 +23820,7 @@ var ts; } function addTypeToUnion(typeSet, type) { var flags = type.flags; - if (flags & 524288) { + if (flags & 65536) { addTypesToUnion(typeSet, type.types); } else if (flags & 1) { @@ -23770,7 +23831,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096) typeSet.containsNull = true; - if (!(flags & 33554432)) + if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192)) { @@ -23783,7 +23844,8 @@ var ts; var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & 2097152 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + if (!(flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } } @@ -23845,7 +23907,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 && types.containsString || t.flags & 64 && types.containsNumber || - t.flags & 96 && t.flags & 16777216 && containsType(types, t.regularType); + t.flags & 96 && t.flags & 1048576 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -23887,22 +23949,22 @@ var ts; var type = unionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createObjectType(524288 | propagatedFlags); + type = unionTypes[id] = createType(65536 | propagatedFlags); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), false, aliasSymbol, aliasTypeArguments); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), false, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } function addTypeToIntersection(typeSet, type) { - if (type.flags & 1048576) { + if (type.flags & 131072) { addTypesToIntersection(typeSet, type.types); } else if (type.flags & 1) { @@ -23922,6 +23984,17 @@ var ts; if (types.length === 0) { return emptyObjectType; } + 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_2(i); + if (typeof state_2 === "object") + return state_2.value; + } var typeSet = []; addTypesToIntersection(typeSet, types); if (typeSet.containsAny) { @@ -23934,39 +24007,248 @@ var ts; var type = intersectionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createObjectType(1048576 | propagatedFlags); + type = intersectionTypes[id] = createType(131072 | propagatedFlags); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), aliasSymbol, aliasTypeArguments); + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return getDeclarationModifierFlagsFromSymbol(prop) & 24 || 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) { - var type = createObjectType(2097152, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = getIndexType(getTypeFromTypeNode(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 === 178 ? 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 === 178 ? 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 (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + 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(getTypeFromTypeNode(node.objectType), getTypeFromTypeNode(node.indexType), node); + } + return links.resolvedType; + } + function getTypeFromMappedTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = createObjectType(32, node.symbol); + type.declaration = node; + type.aliasSymbol = getAliasSymbolForTypeNode(node); + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); links.resolvedType = type; } return links.resolvedType; } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + links.resolvedType = type; + } + } + return links.resolvedType; + } + function getAliasSymbolForTypeNode(node) { + return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + } + function getAliasTypeArgumentsForTypeNode(node) { + var symbol = getAliasSymbolForTypeNode(node); + return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; + } + 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 & 16777216)) { + if (type.flags & 96 && !(type.flags & 1048576)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 16777216, type.text); + var freshType = createLiteralType(type.flags | 1048576, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -23975,7 +24257,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 16777216 ? type.regularType : type; + return type.flags & 96 && type.flags & 1048576 ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; @@ -23999,7 +24281,7 @@ var ts; function getTypeFromJSDocTupleType(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var types = ts.map(node.types, getTypeFromTypeNodeNoAlias); + var types = ts.map(node.types, getTypeFromTypeNode); links.resolvedType = createTupleType(types); } return links.resolvedType; @@ -24007,9 +24289,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 === 227)) { 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; } } @@ -24023,85 +24305,88 @@ var ts; } return links.resolvedType; } - function getTypeFromTypeNodeNoAlias(type) { - return getTypeFromTypeNode(type, undefined, undefined); - } - function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 258: - case 259: + case 263: + case 264: 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 288: return nullType; - case 284: + case 289: return undefinedType; - case 285: + case 290: return neverType; - case 166: + case 167: case 98: return getTypeFromThisTypeNode(node); - case 167: + case 171: return getTypeFromLiteralTypeNode(node); - case 282: + case 287: 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 272: + return getTypeFromTypeReference(node); + case 156: + return booleanType; + case 199: + return getTypeFromTypeReference(node); case 160: - case 281: + return getTypeFromTypeQueryNode(node); + case 162: + case 265: + return getTypeFromArrayTypeNode(node); + case 163: + return getTypeFromTupleTypeNode(node); + case 164: + case 266: + return getTypeFromUnionTypeNode(node); + case 165: + return getTypeFromIntersectionTypeNode(node); + case 166: + case 268: case 269: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 276: + case 277: + case 273: + return getTypeFromTypeNode(node.type); + case 270: + return getTypeFromTypeNode(node.literal); + case 158: + case 159: + case 161: + case 286: + case 274: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 168: + return getTypeFromTypeOperatorNode(node); + case 169: + return getTypeFromIndexedAccessTypeNode(node); + case 170: + return getTypeFromMappedTypeNode(node); case 70: - case 140: + case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262: + case 267: return getTypeFromJSDocTupleType(node); - case 270: + case 275: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24118,6 +24403,16 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } + function instantiateCached(type, mapper, instantiator) { + var instantiations = mapper.instantiations || (mapper.instantiations = []); + return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -24140,7 +24435,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) { @@ -24230,45 +24524,46 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - var result = createObjectType(2097152 | 4194304, type.symbol); - result.target = type; - result.mapper = mapper; + var result = createObjectType(16 | 64, type.symbol); + result.target = type.objectFlags & 64 ? type.target : type; + result.mapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; - mapper.instantiations[type.id] = result; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + return result; + } + function instantiateMappedType(type, mapper) { + var result = createObjectType(32 | 64, type.symbol); + result.declaration = type.declaration; + result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + result.aliasSymbol = type.aliasSymbol; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); 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 225: 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 184: + case 185: + case 226: + case 197: + case 227: + case 228: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24278,69 +24573,97 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223) { + if (ts.isClassLike(node) || node.kind === 227) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226: - case 256: + case 230: + case 261: return false; } node = node.parent; } return false; } + function isTopLevelTypeAlias(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var parentKind = symbol.declarations[0].parent.kind; + return parentKind === 261 || parentKind === 231; + } + return false; + } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.flags & 16384) { - return mapper(type); + if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { + if (type.aliasTypeArguments) { + return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + return type; } - if (type.flags & 2097152) { + return instantiateTypeNoAlias(type, mapper); + } + return type; + } + function instantiateTypeNoAlias(type, mapper) { + if (type.flags & 16384) { + return mapper(type); + } + if (type.flags & 32768) { + if (type.objectFlags & 16) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && - (type.flags & 4194304 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateAnonymousType(type, mapper) : type; + (type.objectFlags & 64 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? + instantiateCached(type, mapper, instantiateAnonymousType) : type; } - if (type.flags & 131072) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + if (type.objectFlags & 32) { + return instantiateCached(type, mapper, instantiateMappedType); } - if (type.flags & 524288 && !(type.flags & 8190)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), false, type.aliasSymbol, mapper.targetTypes); - } - if (type.flags & 1048576) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + if (type.objectFlags & 4) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } + if (type.flags & 65536 && !(type.flags & 8190)) { + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 131072) { + 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; } function instantiateIndexInfo(info, mapper) { 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 184: + case 185: return isContextSensitiveFunctionLikeDeclaration(node); - case 172: + case 176: return ts.forEach(node.properties, isContextSensitive); - case 171: + case 175: return ts.forEach(node.elements, isContextSensitive); - case 189: + case 193: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188: + case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253: + case 257: return isContextSensitive(node.initializer); + case 149: case 148: - case 147: return isContextSensitiveFunctionLikeDeclaration(node); - case 179: + case 183: return isContextSensitive(node.expression); } return false; @@ -24352,7 +24675,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 181) { + if (node.kind === 185) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -24362,10 +24685,10 @@ var ts; return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(2097152, type.symbol); + var result = createObjectType(16, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -24544,7 +24867,7 @@ var ts; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || - (source.flags & 524288) !== (target.flags & 524288)) { + (source.flags & 65536) !== (target.flags & 65536)) { return enumRelation[id] = false; } var targetEnumType = getTypeOfSymbol(target.symbol); @@ -24601,23 +24924,23 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 16777216) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 16777216) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 2588672 && target.flags & 2588672) { + if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related === 1; } } - if (source.flags & 4177920 || target.flags & 4177920) { + if (source.flags & 507904 || target.flags & 507904) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -24654,9 +24977,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); } @@ -24672,10 +25001,10 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 && source.flags & 16777216) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 16777216) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target) @@ -24685,19 +25014,24 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (source.flags & 8388608 && source.flags & 16777216) { + if (source.flags & 262144) { + if (maybeTypeOfKind(target, 2) && maybeTypeOfKind(target, 4)) { + return -1; + } + } + if (getObjectFlags(source) & 128 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); } return 0; } - if (target.flags & 1572864) { + if (target.flags & 196608) { source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 524288) { + if (source.flags & 65536) { if (relation === comparableRelation) { result = someTypeRelatedToType(source, target, reportErrors && !(source.flags & 8190)); } @@ -24708,20 +25042,38 @@ var ts; return result; } } - else if (target.flags & 1048576) { - result = typeRelatedToEachType(source, target, reportErrors); - if (result) { + else if (target.flags & 65536) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { return result; } } - else { - if (source.flags & 1048576) { - if (result = someTypeRelatedToType(source, target, false)) { + else if (target.flags & 131072) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072) { + if (result = someTypeRelatedToType(source, target, false)) { + return result; + } + } + if (target.flags & 16384) { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { return result; } } - if (target.flags & 524288) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { + } + else if (target.flags & 262144) { + if (source.flags & 262144) { + if (result = isRelatedTo(target.type, source.type, false)) { + return result; + } + } + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { return result; } } @@ -24739,25 +25091,35 @@ var ts; } } else { - if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } - var apparentSource = getApparentType(source); - if (apparentSource.flags & (2588672 | 1048576) && target.flags & 2588672) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; + if (isGenericMappedType(target)) { + if (isGenericMappedType(source)) { + if ((result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) && + (result = isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors))) { + return result; + } + } + } + else { + var apparentSource = getApparentType(source); + if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } if (reportErrors) { - if (source.flags & 2588672 && target.flags & 8190) { + if (source.flags & 32768 && target.flags & 8190) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 2588672 && globalObjectType === source) { + else if (source.symbol && source.flags & 32768 && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } reportRelationError(headMessage, source, target); @@ -24766,16 +25128,16 @@ var ts; } function isIdenticalTo(source, target) { var result; - if (source.flags & 2588672 && target.flags & 2588672) { - if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + if (source.flags & 32768 && target.flags & 32768) { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } return objectTypeRelatedTo(source, source, target, false); } - if (source.flags & 524288 && target.flags & 524288 || - source.flags & 1048576 && target.flags & 1048576) { + if (source.flags & 65536 && target.flags & 65536 || + source.flags & 131072 && target.flags & 131072) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -24785,7 +25147,7 @@ var ts; return 0; } function isKnownProperty(type, name) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || @@ -24794,7 +25156,7 @@ var ts; return true; } } - else if (type.flags & 1572864) { + else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name)) { @@ -24812,8 +25174,7 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (maybeTypeOfKind(target, 2588672) && - (!(target.flags & 2588672) || !target.isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -24843,7 +25204,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 524288 && containsType(targetTypes, source)) { + if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } var len = targetTypes.length; @@ -24870,7 +25231,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 524288 && containsType(sourceTypes, target)) { + if (source.flags & 65536 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; @@ -24990,9 +25351,9 @@ var ts; } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 8388608); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); + 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) { @@ -25044,7 +25405,7 @@ var ts; return 0; } result &= related; - if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -25056,7 +25417,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 2588672 && target.flags & 2588672)) { + if (!(source.flags & 32768 && target.flags & 32768)) { return 0; } var sourceProperties = getPropertiesOfObjectType(source); @@ -25228,7 +25589,7 @@ var ts; } } function isAbstractConstructorType(type) { - if (type.flags & 2097152) { + if (getObjectFlags(type) & 16) { var symbol = type.symbol; if (symbol && symbol.flags & 32) { var declaration = getClassLikeDeclarationOfSymbol(symbol); @@ -25240,12 +25601,12 @@ var ts; return false; } function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (131072 | 4194304) && depth >= 5) { + if (getObjectFlags(type) & (4 | 64) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (131072 | 4194304) && t.symbol === symbol) { + if (getObjectFlags(t) & (4 | 64) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -25403,10 +25764,10 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isArrayType(type) { - return type.flags & 131072 && type.target === globalArrayType; + return getObjectFlags(type) & 4 && type.target === globalArrayType; } function isArrayLikeType(type) { - return type.flags & 131072 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + return getObjectFlags(type) & 4 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || !(type.flags & 6144) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { @@ -25417,7 +25778,7 @@ var ts; } function isLiteralType(type) { return type.flags & 8 ? true : - type.flags & 524288 ? type.flags & 16 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + type.flags & 65536 ? type.flags & 16 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { @@ -25425,19 +25786,19 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 32 && type.flags & 16777216 ? stringType : - type.flags & 64 && type.flags & 16777216 ? 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 & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { - return !!(type.flags & 131072 && type.target.flags & 262144); + return !!(getObjectFlags(type) & 4 && type.target.objectFlags & 8); } function getFalsyFlagsOfTypes(types) { var result = 0; @@ -25448,7 +25809,7 @@ var ts; return result; } function getFalsyFlags(type) { - return type.flags & 524288 ? getFalsyFlagsOfTypes(type.types) : + return type.flags & 65536 ? getFalsyFlagsOfTypes(type.types) : type.flags & 32 ? type.text === "" ? 32 : 0 : type.flags & 64 ? type.text === "0" ? 64 : 0 : type.flags & 128 ? type === falseType ? 128 : 0 : @@ -25509,7 +25870,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(type.flags & 8388608 && type.flags & 16777216)) { + if (!(getObjectFlags(type) & 128 && type.flags & 1048576)) { return type; } var regularType = type.regularType; @@ -25519,7 +25880,8 @@ 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 & ~16777216; + regularNew.flags = resolved.flags & ~1048576; + regularNew.objectFlags |= 128; type.regularType = regularNew; return regularNew; } @@ -25536,14 +25898,14 @@ var ts; return type.flags & 6144 ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 100663296) { + if (type.flags & 6291456) { if (type.flags & 6144) { return anyType; } - if (type.flags & 8388608) { + if (getObjectFlags(type) & 128) { return getWidenedTypeOfObjectLiteral(type); } - if (type.flags & 524288) { + if (type.flags & 65536) { return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { @@ -25554,7 +25916,7 @@ var ts; } function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 524288) { + if (type.flags & 65536) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (reportWideningErrorsInType(t)) { @@ -25570,11 +25932,11 @@ var ts; } } } - if (type.flags & 8388608) { + if (getObjectFlags(type) & 128) { for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 33554432) { + 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))); } @@ -25588,25 +25950,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 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221: + case 225: + case 149: case 148: - case 147: - case 150: case 151: - case 180: - case 181: + case 152: + case 184: + case 185: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25619,7 +25981,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 33554432) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -25663,10 +26025,12 @@ var ts; }; } function couldContainTypeParameters(type) { + var objectFlags = getObjectFlags(type); return !!(type.flags & 16384 || - type.flags & 131072 && ts.forEach(type.typeArguments, couldContainTypeParameters) || - type.flags & 2097152 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) || - type.flags & 1572864 && couldUnionOrIntersectionContainTypeParameters(type)); + objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeParameters) || + objectFlags & 16 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) || + objectFlags & 32 || + type.flags & 196608 && couldUnionOrIntersectionContainTypeParameters(type)); } function couldUnionOrIntersectionContainTypeParameters(type) { if (type.couldContainTypeParameters === undefined) { @@ -25675,7 +26039,7 @@ var ts; return type.couldContainTypeParameters; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 1572864 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || type.flags & 196608 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function inferTypes(context, originalSource, originalTarget) { var typeParameters = context.signature.typeParameters; @@ -25697,8 +26061,16 @@ var ts; if (!couldContainTypeParameters(target)) { return; } - if (source.flags & 524288 && target.flags & 524288 && !(source.flags & 16 && target.flags & 16) || - source.flags & 1048576 && target.flags & 1048576) { + if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { + var sourceTypes = source.aliasTypeArguments; + var targetTypes = target.aliasTypeArguments; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + return; + } + if (source.flags & 65536 && target.flags & 65536 && !(source.flags & 16 && target.flags & 16) || + source.flags & 131072 && target.flags & 131072) { if (source === target) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -25726,7 +26098,7 @@ var ts; } } if (target.flags & 16384) { - if (source.flags & 134217728) { + if (source.flags & 8388608) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -25747,7 +26119,7 @@ var ts; } } } - else if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + else if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { var sourceTypes = source.typeArguments || emptyArray; var targetTypes = target.typeArguments || emptyArray; var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -25755,7 +26127,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 1572864) { + else if (target.flags & 196608) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter = void 0; @@ -25775,7 +26147,7 @@ var ts; inferiority--; } } - else if (source.flags & 1572864) { + else if (source.flags & 196608) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -25783,8 +26155,21 @@ var ts; } } else { + if (getObjectFlags(target) & 32) { + var constraintType = getConstraintTypeFromMappedType(target); + if (getObjectFlags(source) & 32) { + inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + return; + } + if (constraintType.flags & 16384) { + inferFromTypes(getIndexType(source), constraintType); + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return; + } + } source = getApparentType(source); - if (source.flags & 2588672) { + if (source.flags & 32768) { if (isInProcess(source, target)) { return; } @@ -25813,8 +26198,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)); @@ -25880,7 +26265,7 @@ var ts; reducedTypes.push(t); } } - return type.flags & 524288 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 65536 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function getInferenceCandidates(context, index) { var inferences = context.inferences[index]; @@ -25888,7 +26273,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]; @@ -25941,10 +26326,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: @@ -25961,7 +26346,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 173) { + if (node.kind === 177) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -25972,7 +26357,7 @@ var ts; case 70: case 98: return node; - case 173: + case 177: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -25981,19 +26366,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 || target.kind === 170) && + (target.kind === 223 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 173: - return target.kind === 173 && + case 177: + return target.kind === 177 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173) { + while (source.kind === 177) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26002,7 +26387,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 && + return target.kind === 177 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -26010,14 +26395,14 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173) { + if (expr.kind === 177) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 524288) { + if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456) { if (prop.isDiscriminantProperty === undefined) { @@ -26040,7 +26425,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 && + if (callExpression.expression.kind === 177 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26054,7 +26439,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 524288)) { + if (!(source.flags & 65536)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -26117,7 +26502,7 @@ var ts; type === falseType ? 3030404 : 1981828 : type === falseType ? 3145092 : 4193668; } - if (flags & 2588672) { + if (flags & 32768) { return isFunctionObjectType(type) ? strictNullChecks ? 6164448 : 8376288 : strictNullChecks ? 6166480 : 8378320; @@ -26135,7 +26520,7 @@ var ts; var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); } - if (flags & 1572864) { + if (flags & 196608) { return getTypeFactsOfTypes(type.types); } return 8388607; @@ -26151,7 +26536,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) || @@ -26162,19 +26547,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 === 175 || node.parent.kind === 257 ? 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); @@ -26185,21 +26570,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208: + case 212: return stringType; - case 209: + case 213: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188: - return getAssignedTypeOfBinaryExpression(parent); - case 182: - return undefinedType; - case 171: - return getAssignedTypeOfArrayLiteralElement(parent, node); case 192: - return getAssignedTypeOfSpreadElement(parent); - case 253: + return getAssignedTypeOfBinaryExpression(parent); + case 186: + return undefinedType; + case 175: + return getAssignedTypeOfArrayLiteralElement(parent, node); + case 196: + return getAssignedTypeOfSpreadExpression(parent); + case 257: return getAssignedTypeOfPropertyAssignment(parent); - case 254: + case 258: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -26207,11 +26592,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 ? + var type = pattern.kind === 172 ? 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) { @@ -26222,35 +26607,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 212) { return stringType; } - if (node.parent.parent.kind === 209) { + if (node.parent.parent.kind === 213) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 ? + return node.kind === 223 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 || node.kind === 170 ? + return node.kind === 223 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 && node.initializer && + return node.kind === 223 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 && node.parent.kind === 188 && + node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179: + case 183: return getReferenceCandidate(node.expression); - case 188: + case 192: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -26262,13 +26647,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 === 183 || + parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249) { + if (clause.kind === 253) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -26283,13 +26668,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 524288 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 65536 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 524288 && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 65536 && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 524288) { + if (source.flags & 65536) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -26303,8 +26688,11 @@ var ts; } return containsType(target.types, source); } + function forEachType(type, f) { + return type.flags & 65536 ? ts.forEach(type.types, f) : f(type); + } function filterType(type, f) { - if (type.flags & 524288) { + if (type.flags & 65536) { var types = type.types; var filtered = ts.filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered); @@ -26312,7 +26700,7 @@ var ts; return f(type) ? type : neverType; } function mapType(type, f) { - return type.flags & 524288 ? getUnionType(ts.map(type.types, f)) : f(type); + return type.flags & 65536 ? getUnionType(ts.map(type.types, f)) : f(type); } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -26338,7 +26726,7 @@ var ts; return incomplete ? { flags: 0, type: type } : type; } function createEvolvingArrayType(elementType) { - var result = createObjectType(2097152); + var result = createObjectType(256); result.elementType = elementType; return result; } @@ -26349,13 +26737,10 @@ var ts; var elementType = getBaseTypeOfLiteralType(checkExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } - function isEvolvingArrayType(type) { - return !!(type.flags & 2097152 && type.elementType); - } function createFinalArrayType(elementType) { return elementType.flags & 8192 ? autoArrayType : - createArrayType(elementType.flags & 524288 ? + createArrayType(elementType.flags & 65536 ? getUnionType(elementType.types, true) : elementType); } @@ -26363,17 +26748,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return getObjectFlags(type) & 256 ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? type.elementType : neverType; + return getObjectFlags(type) & 256 ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { var t = types_12[_i]; if (!(t.flags & 8192)) { - if (!isEvolvingArrayType(t)) { + if (!(getObjectFlags(t) & 256)) { return false; } hasEvolvingArrayType = true; @@ -26389,20 +26774,40 @@ 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 === 177 && (parent.name.text === "length" || + parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 178 && parent.expression === root && - parent.parent.kind === 188 && + parent.parent.kind === 192 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); return isLengthPushOrUnshift || isElementAssignment; } + function maybeTypePredicateCall(node) { + var links = getNodeLinks(node); + if (links.maybeTypePredicate === undefined) { + links.maybeTypePredicate = getMaybeTypePredicate(node); + } + return links.maybeTypePredicate; + } + function getMaybeTypePredicate(node) { + if (node.expression.kind !== 96) { + var funcType = checkNonNullExpression(node.expression); + if (funcType !== silentNeverType) { + var apparentType = getApparentType(funcType); + if (apparentType !== unknownType) { + var callSignatures = getSignaturesOfType(apparentType, 0); + return !!ts.forEach(callSignatures, function (sig) { return sig.typePredicate; }); + } + } + } + return false; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -26411,8 +26816,8 @@ var ts; var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { + var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -26457,7 +26862,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 !== 177) { flow = container.flowNode; continue; } @@ -26477,7 +26882,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)); } @@ -26488,7 +26893,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 524288) { + if (declaredType.flags & 65536) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -26500,15 +26905,15 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 ? + var expr = node.kind === 179 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (isEvolvingArrayType(type)) { + if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 175) { + if (node.kind === 179) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -26626,8 +27031,8 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 && - declaredType.flags & 524288 && + return expr.kind === 177 && + declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); } @@ -26660,10 +27065,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 === 187 && 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 === 187 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26709,7 +27114,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 2589185) { + if (type.flags & 33281) { return type; } if (assumeTrue) { @@ -26733,7 +27138,7 @@ var ts; if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 524288)) { + if (assumeTrue && !(type.flags & 65536)) { var targetType = typeofTypesByName[literal.text]; if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; @@ -26785,10 +27190,10 @@ var ts; } if (!targetType) { var constructSignatures = void 0; - if (rightType.flags & 65536) { + if (getObjectFlags(rightType) & 2) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 2097152) { + else if (getObjectFlags(rightType) & 16) { constructSignatures = getSignaturesOfType(rightType, 1); } if (constructSignatures && constructSignatures.length) { @@ -26804,7 +27209,7 @@ var ts; if (!assumeTrue) { return filterType(type, function (t) { return !isTypeInstanceOf(t, candidate); }); } - if (type.flags & 524288) { + if (type.flags & 65536) { var assignableType = filterType(type, function (t) { return isTypeInstanceOf(t, candidate); }); if (!(assignableType.flags & 8192)) { return assignableType; @@ -26817,7 +27222,7 @@ var ts; getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { return type; } var signature = getResolvedSignature(callExpression); @@ -26840,10 +27245,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 === 178 || invokedExpression.kind === 177) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -26858,15 +27263,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 177: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175: - return narrowTypeByTypePredicate(type, expr, assumeTrue); case 179: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 183: return narrowType(type, expr.expression, assumeTrue); - case 188: + case 192: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186: + case 190: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -26889,19 +27294,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 === 231 || + node.kind === 261 || + node.kind === 147) { return node; } } @@ -26932,7 +27331,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; } } @@ -26946,19 +27345,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 === 185) { 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); @@ -26967,7 +27370,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 222 + && declaration_1.kind === 226 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -26979,11 +27382,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193) { + else if (declaration_1.kind === 197) { 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; } @@ -26998,15 +27401,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 === 184 || + flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -27027,7 +27441,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; @@ -27042,7 +27456,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 252) { + symbol.valueDeclaration.parent.kind === 256) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27060,8 +27474,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 207 && - ts.getAncestor(symbol.valueDeclaration, 220).parent === container && + if (container.kind === 211 && + ts.getAncestor(symbol.valueDeclaration, 224).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27073,14 +27487,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 179) { + while (current.parent.kind === 183) { 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 === 190 || current.parent.kind === 191)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -27099,7 +27513,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; } @@ -27133,7 +27547,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)) { @@ -27143,29 +27557,29 @@ var ts; } } } - if (container.kind === 181) { + if (container.kind === 185) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 226: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 225: + case 229: 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; } @@ -27174,7 +27588,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 180 && + if (container.kind === 184 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27209,27 +27623,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 === 274) { 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 === 277) { 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 === 179 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 181) { + while (container && container.kind === 185) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27238,16 +27652,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 === 176)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27262,7 +27676,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; } @@ -27273,7 +27687,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172) { + if (container.parent.kind === 176) { 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; @@ -27291,7 +27705,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; } @@ -27303,24 +27717,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 === 176) { 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; } } } @@ -27328,7 +27742,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -27384,7 +27798,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; @@ -27395,11 +27809,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); } @@ -27436,7 +27850,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; @@ -27445,8 +27859,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); @@ -27465,7 +27879,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177) { + if (template.parent.kind === 181) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27496,7 +27910,7 @@ var ts; return undefined; } function applyToContextualType(type, mapper) { - if (!(type.flags & 524288)) { + if (!(type.flags & 65536)) { return mapper(type); } var types = type.types; @@ -27521,7 +27935,7 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = t.flags & 4161536 ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 229376 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } @@ -27529,7 +27943,7 @@ var ts; return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 524288 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 65536 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -27573,13 +27987,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246) { + if (attribute.kind === 250) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247) { + else if (attribute.kind === 251) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -27597,56 +28011,70 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219: - case 143: + case 223: + case 144: + case 147: case 146: - case 145: - case 170: + case 174: return getContextualTypeForInitializerExpression(node); - case 181: - case 212: + case 185: + case 216: return getContextualTypeForReturnExpression(node); - case 191: + case 195: 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: + case 180: + return getContextualTypeForArgument(parent, node); + case 182: + case 200: + return getTypeFromTypeNode(parent.type); + case 192: + return getContextualTypeForBinaryOperand(node); + case 257: + case 258: + return getContextualTypeForObjectLiteralElement(parent); + case 175: + return getContextualTypeForElementExpression(node); + case 193: + return getContextualTypeForConditionalOperand(node); + case 202: + ts.Debug.assert(parent.parent.kind === 194); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 183: return getContextualType(parent); - case 248: + case 252: return getContextualType(parent); - case 246: - case 247: + case 250: + case 251: return getContextualTypeForJsxAttribute(parent); } return undefined; } - function getNonGenericSignature(type) { + function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { var signature = signatures[0]; - if (!signature.typeParameters) { + if (!signature.typeParameters && !isAritySmaller(signature, node)) { return signature; } } } + function isAritySmaller(signature, target) { + var targetParameterCount = 0; + for (; targetParameterCount < target.parameters.length; targetParameterCount++) { + var param = target.parameters[targetParameterCount]; + if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { + break; + } + } + if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { + targetParameterCount--; + } + var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; + return sourceLength < targetParameterCount; + } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 || node.kind === 181; + return node.kind === 184 || node.kind === 185; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27659,19 +28087,19 @@ 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; } - if (!(type.flags & 524288)) { - return getNonGenericSignature(type); + if (!(type.flags & 65536)) { + return getNonGenericSignature(type, node); } var signatureList; var types = type.types; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var current = types_14[_i]; - var signature = getNonGenericSignature(current); + var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { signatureList = [signature]; @@ -27695,13 +28123,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 === 174 && !!node.initializer) || + (node.kind === 192 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27710,7 +28138,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 === 196) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27722,7 +28150,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192; + hasSpreadElement = hasSpreadElement || e.kind === 196; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27733,7 +28161,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 === 173 || pattern.kind === 175)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27741,7 +28169,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194) { + if (patternElement.kind !== 198) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27758,7 +28186,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); @@ -27800,9 +28228,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 === 172 || contextualType.pattern.kind === 176); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27810,25 +28240,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 === 257 || + memberDecl.kind === 258 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253) { + if (memberDecl.kind === 257) { 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 === 258); 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 === 257 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -27836,8 +28266,7 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & 2588672 && contextualType.isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; @@ -27855,8 +28284,25 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 259) { + 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)) { @@ -27884,18 +28330,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 : 16777216; - result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024); - if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + 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 |= 128; + if (patternWithComputedProperties) { + result.objectFlags |= 512; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144)) { + propagatedFlags |= (result.flags & 14680064); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -27912,13 +28373,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248: + case 252: checkJsxExpression(child); break; - case 242: + case 246: checkJsxElement(child); break; - case 243: + case 247: checkJsxSelfClosingElement(child); break; } @@ -27929,7 +28390,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 173 || tagName.kind === 98) { + if (tagName.kind === 177 || tagName.kind === 98) { return false; } else { @@ -27945,7 +28406,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; } @@ -28020,7 +28481,7 @@ var ts; return links.resolvedSymbol; } function getJsxElementInstanceType(node, valueType) { - ts.Debug.assert(!(valueType.flags & 524288)); + ts.Debug.assert(!(valueType.flags & 65536)); if (isTypeAny(valueType)) { return anyType; } @@ -28059,7 +28520,7 @@ var ts; if (!elemType) { elemType = checkExpression(node.tagName); } - if (elemType.flags & 524288) { + if (elemType.flags & 65536) { var types = elemType.types; return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); @@ -28121,7 +28582,7 @@ var ts; else if (isTypeAny(attributesType) || (attributesType === unknownType)) { return attributesType; } - else if (attributesType.flags & 524288) { + else if (attributesType.flags & 65536) { error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } @@ -28198,20 +28659,23 @@ 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) { - getSymbolLinks(reactSym).referenced = true; + reactSym.isReferenced = true; + if (reactSym.flags & 8388608 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + markAliasSymbolAsReferenced(reactSym); + } } var targetAttributesType = getJsxElementAttributesType(node); 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 === 250) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247); + ts.Debug.assert(node.attributes[i].kind === 251); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -28237,7 +28701,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; @@ -28248,11 +28712,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 === 177 || node.kind === 223 ? 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; } @@ -28289,7 +28753,7 @@ var ts; if (type.flags & 16384 && type.isThisType) { type = getConstraintOfTypeParameter(type); } - if (!(getTargetType(type).flags & (32768 | 65536) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & 3 && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -28315,6 +28779,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) { @@ -28331,44 +28822,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 !== 177 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && - !(prop.flags & 8192 && propType.flags & 524288)) { + !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - return getFlowTypeOfReference(node, propType, true, undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 524288 && !(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 === 177 ? node.expression : node.left; var type = checkExpression(left); @@ -28382,7 +28858,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220) { + if (initializer.kind === 224) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -28397,14 +28873,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 === 212 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28418,9 +28894,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 === 180 && 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); @@ -28430,71 +28908,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) { @@ -28527,10 +28951,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177) { + if (node.kind === 181) { checkExpression(node.template); } - else if (node.kind !== 144) { + else if (node.kind !== 145) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28552,19 +28976,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_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -28581,7 +29005,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 === 196) { return i; } } @@ -28594,11 +29018,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177) { + if (node.kind === 181) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190) { + if (tagExpression.template.kind === 194) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28610,7 +29034,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); @@ -28618,7 +29042,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 176); + ts.Debug.assert(callExpression.kind === 180); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28641,7 +29065,7 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -28677,7 +29101,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 !== 198) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -28724,7 +29148,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 !== 180) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28737,7 +29161,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 !== 198) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -28752,28 +29176,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 175) { + if (node.kind === 179) { var callee = node.expression; - if (callee.kind === 173) { + if (callee.kind === 177) { return callee.expression; } - else if (callee.kind === 174) { + else if (callee.kind === 178) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 177) { + if (node.kind === 181) { var template = node.template; args = [undefined]; - if (template.kind === 190) { + if (template.kind === 194) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144) { + else if (node.kind === 145) { return undefined; } else { @@ -28782,21 +29206,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 226: + case 197: 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; } } @@ -28805,48 +29229,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 226) { 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 === 226) { 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; @@ -28863,20 +29287,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 226) { 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); } @@ -28897,26 +29321,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 === 181) { 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 === 181)) { 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 === 181) { return node.template; } else { @@ -28924,8 +29348,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177; - var isDecorator = node.kind === 144; + var isTaggedTemplate = node.kind === 181; + var isDecorator = node.kind === 145; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -28955,7 +29379,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -28974,7 +29398,7 @@ var ts; else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { var typeArguments_2 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNodeNoAlias), true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -28995,7 +29419,7 @@ var ts; var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNodeNoAlias)); + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); } return candidate; } @@ -29027,7 +29451,7 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNodeNoAlias); + typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { @@ -29116,7 +29540,7 @@ var ts; return true; } if (!numCallSignatures && !numConstructSignatures) { - if (funcType.flags & 524288) { + if (funcType.flags & 65536) { return false; } return isTypeAssignableTo(funcType, globalFunctionType); @@ -29223,16 +29647,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222: - case 193: + case 226: + case 197: 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; } } @@ -29259,13 +29683,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175: + case 179: return resolveCallExpression(node, candidatesOutArray); - case 176: + case 180: return resolveNewExpression(node, candidatesOutArray); - case 177: + case 181: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144: + case 145: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29297,12 +29721,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 176) { + if (node.kind === 180) { 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) : @@ -29316,13 +29740,33 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && - ts.isRequireCall(node, true) && - !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { + if (ts.isInJavaScriptFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); } + function isCommonJsRequire(node) { + if (!ts.isRequireCall(node, true)) { + return false; + } + var resolvedRequire = resolveName(node.expression, node.expression.text, 107455, undefined, undefined); + if (!resolvedRequire) { + return true; + } + if (resolvedRequire.flags & 8388608) { + return false; + } + var targetDeclarationKind = resolvedRequire.flags & 16 + ? 225 + : resolvedRequire.flags & 3 + ? 223 + : 0; + if (targetDeclarationKind !== 0) { + var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + return ts.isInAmbientContext(decl); + } + return false; + } function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } @@ -29408,8 +29852,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 === 172 || + parameter.valueDeclaration.name.kind === 173)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29436,7 +29880,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; @@ -29448,7 +29892,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200) { + if (func.body.kind !== 204) { 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); @@ -29527,7 +29971,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29556,7 +30000,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 || func.kind === 181)) { + func.kind === 184 || func.kind === 185)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29573,7 +30017,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 !== 204 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29600,9 +30044,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 === 184) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29636,14 +30080,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) { @@ -29653,7 +30097,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200) { + if (node.body.kind === 204) { checkSourceElement(node.body); } else { @@ -29688,10 +30132,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 173 || expr.kind === 174) && + (expr.kind === 177 || expr.kind === 178) && 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); } @@ -29700,44 +30144,24 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 || expr.kind === 174) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 177 || expr.kind === 178) { + 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 === 237; } } } 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 !== 177 && node.kind !== 178) { 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) { @@ -29754,7 +30178,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)) { @@ -29789,7 +30213,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; } @@ -29802,7 +30226,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; } @@ -29810,7 +30234,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 1572864) { + if (type.flags & 196608) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -29825,7 +30249,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 524288) { + if (type.flags & 65536) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -29835,7 +30259,7 @@ var ts; } return true; } - if (type.flags & 1048576) { + if (type.flags & 131072) { var types = type.types; for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { var t = types_17[_a]; @@ -29847,7 +30271,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (2588672 | 2097152) && type.symbol && isConstEnumSymbol(type.symbol); + return getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; @@ -29871,36 +30295,36 @@ var ts; if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 | 340 | 512)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } 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 === 257 || property.kind === 258) { + 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 === 258) { return checkDestructuringAssignment(property, type); } else { @@ -29908,7 +30332,12 @@ 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 if (property.kind === 259) { + if (property.expression.kind !== 70) { + error(property.expression, ts.Diagnostics.An_object_rest_element_must_be_an_identifier); } } else { @@ -29926,8 +30355,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 !== 198) { + if (element.kind !== 196) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -29949,11 +30378,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 === 192 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -29966,7 +30395,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254) { + if (exprOrAssignment.kind === 258) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -29980,21 +30409,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 && target.operatorToken.kind === 57) { + if (target.kind === 192 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172) { + if (target.kind === 176) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171) { + if (target.kind === 175) { 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; @@ -30005,35 +30434,35 @@ var ts; case 70: case 9: case 11: - case 177: - case 190: + case 181: + case 194: case 12: case 8: case 100: case 85: case 94: - case 136: - case 180: - case 193: - case 181: - case 171: - case 172: - case 183: + case 137: + case 184: case 197: - case 243: - case 242: + case 185: + case 175: + case 176: + case 187: + case 201: + case 247: + case 246: return true; - case 189: + case 193: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188: + case 192: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186: - case 187: + case 190: + case 191: switch (node.operator) { case 50: case 36: @@ -30042,9 +30471,9 @@ var ts; return true; } return false; - case 184: - case 178: - case 196: + case 188: + case 182: + case 200: default: return false; } @@ -30064,7 +30493,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 === 176 || left.kind === 175)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -30221,8 +30650,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); } } @@ -30248,7 +30676,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)) { @@ -30322,8 +30750,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 === 182 || node.kind === 200; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30349,14 +30777,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); @@ -30379,7 +30807,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140) { + if (node.kind === 141) { type = checkQualifiedName(node); } else { @@ -30387,9 +30815,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 === 177 && node.parent.expression === node) || + (node.parent.kind === 178 && 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); } @@ -30411,66 +30839,66 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 190: + case 194: 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); case 175: + return checkArrayLiteral(node, contextualMapper); case 176: - return checkCallExpression(node); + return checkObjectLiteral(node, contextualMapper); 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 checkPropertyAccessExpression(node); case 178: - case 196: - return checkAssertion(node); + return checkIndexedAccess(node); + case 179: + case 180: + return checkCallExpression(node); + case 181: + return checkTaggedTemplateExpression(node); + case 183: + return checkExpression(node.expression, contextualMapper); case 197: - return checkNonNullAssertion(node); - case 182: - return checkDeleteExpression(node); + return checkClassExpression(node); case 184: - return checkVoidExpression(node); case 185: - return checkAwaitExpression(node); - case 186: - return checkPrefixUnaryExpression(node); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 187: - return checkPostfixUnaryExpression(node); + return checkTypeOfExpression(node); + case 182: + case 200: + return checkAssertion(node); + case 201: + return checkNonNullAssertion(node); + case 186: + return checkDeleteExpression(node); case 188: - return checkBinaryExpression(node, contextualMapper); + return checkVoidExpression(node); case 189: - return checkConditionalExpression(node, contextualMapper); - case 192: - return checkSpreadElementExpression(node, contextualMapper); - case 194: - return undefinedWideningType; + return checkAwaitExpression(node); + case 190: + return checkPrefixUnaryExpression(node); case 191: + return checkPostfixUnaryExpression(node); + case 192: + return checkBinaryExpression(node, contextualMapper); + case 193: + return checkConditionalExpression(node, contextualMapper); + case 196: + return checkSpreadExpression(node, contextualMapper); + case 198: + return undefinedWideningType; + case 195: return checkYieldExpression(node); - case 248: + case 252: return checkJsxExpression(node); - case 242: + case 246: return checkJsxElement(node); - case 243: + case 247: return checkJsxSelfClosingElement(node); - case 244: + case 248: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30491,7 +30919,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); } } @@ -30502,7 +30930,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); } } @@ -30514,9 +30942,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 === 225 || + node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -30557,9 +30985,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; } @@ -30572,16 +31000,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181: - case 152: - case 221: - case 180: - case 157: + case 185: + case 153: + case 225: + case 184: + case 158: + case 149: case 148: - case 147: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -30591,27 +31019,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 === 173 || + name_23.kind === 172) { + 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 === 225 || node.kind === 159 || + node.kind === 153 || node.kind === 150 || + node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30623,10 +31051,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; } @@ -30653,17 +31081,11 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); 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)) { @@ -30677,13 +31099,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; } @@ -30709,7 +31131,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: @@ -30731,7 +31153,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223) { + if (node.kind === 227) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30746,7 +31168,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; } @@ -30754,7 +31176,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131: + case 132: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30813,12 +31235,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 !== 184 && n.kind !== 225) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 && + return n.kind === 147 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30838,7 +31260,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 === 207 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -30861,18 +31283,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)) { @@ -30886,11 +31308,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 !== 176) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -30920,7 +31342,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -30971,14 +31393,25 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } + function checkMappedType(node) { + checkSourceElement(node.typeParameter); + checkSourceElement(node.type); + var type = getTypeFromMappedTypeNode(node); + var constraintType = getConstraintTypeFromMappedType(type); + var keyType = constraintType.flags & 16384 ? getApparentTypeOfTypeParameter(constraintType) : constraintType; + checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint); + } 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 !== 227 && + n.parent.kind !== 226 && + n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31055,7 +31488,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; @@ -31088,11 +31521,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 === 227 || 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 === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31203,16 +31636,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223: + case 227: return 2097152; - case 226: + case 230: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 222: - case 225: + case 226: + case 229: return 2097152 | 1048576; - case 230: + case 234: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31239,7 +31672,7 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (promise.flags & 131072) { + if (getObjectFlags(promise) & 4) { if (promise.target === tryGetGlobalPromiseType() || promise.target === getGlobalPromiseLikeType()) { return promise.typeArguments[0]; @@ -31276,7 +31709,7 @@ var ts; function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); function checkAwaitedTypeWorker(type) { - if (type.flags & 524288) { + if (type.flags & 65536) { var types = []; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -31304,51 +31737,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); @@ -31360,22 +31792,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222: + case 226: 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]); @@ -31383,29 +31815,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) { @@ -31420,21 +31838,27 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 222: + case 226: 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; } } @@ -31453,7 +31877,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)) { @@ -31495,43 +31919,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 261: + case 230: checkUnusedModuleMembers(node); break; - case 222: - case 193: + case 226: + case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223: + case 227: checkUnusedTypeParameters(node); break; - case 200: - case 228: - case 207: - case 208: - case 209: + case 204: + case 232: + case 211: + case 212: + case 213: checkUnusedLocalsAndParameters(node); break; - case 149: - case 180: - case 221: - case 181: - case 148: case 150: + case 184: + case 225: + case 185: + 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; } @@ -31540,43 +31964,57 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_1 = function (key) { + if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 143) { - var parameter = local.valueDeclaration; + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { + !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return error(d.name || d, ts.Diagnostics._0_is_declared_but_never_used, local.name); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } }; for (var key in node.locals) { - _loop_1(key); + _loop_3(key); } } } - function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; + function errorUnusedLocal(node, name) { + if (isIdentifierThatStartsWithUnderScore(node)) { + var declaration = ts.getRootDeclaration(node.parent); + if (declaration.kind === 223 && + (declaration.parent.parent.kind === 212 || + declaration.parent.parent.kind === 213)) { + return; + } + } + error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + } + function parameterNameStartsWithUnderscore(parameterName) { + return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); + } + function isIdentifierThatStartsWithUnderScore(node) { + return node.kind === 70 && node.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { 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) { @@ -31621,7 +32059,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 200) { + if (node.kind === 204) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31643,19 +32081,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; @@ -31706,11 +32144,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 261 && 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)); } } @@ -31718,11 +32156,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 261 && 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)); } } @@ -31730,7 +32168,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 219 && !node.initializer) { + if (node.kind === 223 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31740,25 +32178,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, 224); + var container = varDeclList.parent.kind === 205 && 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 === 204 && ts.isFunctionLike(container.parent) || + container.kind === 231 || + container.kind === 230 || + container.kind === 261); 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); @@ -31767,7 +32205,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 173) { + if (n.kind === 177) { return visit(n.expression); } else if (n.kind === 70) { @@ -31781,7 +32219,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; } @@ -31790,7 +32228,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; @@ -31812,33 +32250,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 === 174) { + 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_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + markPropertyAsReferenced(property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.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 !== 212) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31847,7 +32286,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 !== 212) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -31865,9 +32304,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 === 223 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -31877,8 +32316,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 === 223) || + (left.kind === 223 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -31905,7 +32344,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 === 176) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -31924,7 +32363,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202) { + if (node.thenStatement.kind === 206) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -31941,12 +32380,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220) { + if (node.initializer && node.initializer.kind === 224) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -31964,18 +32403,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 175 || varExpr.kind === 176) { 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); } @@ -31988,7 +32427,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { 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); @@ -31998,18 +32437,18 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 175 || varExpr.kind === 176) { 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); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -32062,7 +32501,7 @@ var ts; } var typeAsIterable = type; if (!typeAsIterable.iterableElementType) { - if ((type.flags & 131072) && type.target === getGlobalIterableType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableType()) { typeAsIterable.iterableElementType = type.typeArguments[0]; } else { @@ -32088,7 +32527,7 @@ var ts; } var typeAsIterator = type; if (!typeAsIterator.iteratorElementType) { - if ((type.flags & 131072) && type.target === getGlobalIteratorType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIteratorType()) { typeAsIterator.iteratorElementType = type.typeArguments[0]; } else { @@ -32123,7 +32562,7 @@ var ts; if (isTypeAny(type)) { return undefined; } - if ((type.flags & 131072) && type.target === getGlobalIterableIteratorType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableIteratorType()) { return type.typeArguments[0]; } return getElementTypeOfIterable(type, undefined) || @@ -32132,8 +32571,12 @@ var ts; function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { ts.Debug.assert(languageVersion < 2); var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 524288) { - arrayType = getUnionType(ts.filter(arrayOrStringType.types, function (t) { return !(t.flags & 34); }), true); + if (arrayOrStringType.flags & 65536) { + var arrayTypes = arrayOrStringType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, true); + } } else if (arrayOrStringType.flags & 34) { arrayType = neverType; @@ -32171,7 +32614,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; @@ -32193,12 +32636,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); } @@ -32216,14 +32659,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); } } @@ -32240,8 +32683,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 === 254 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -32253,11 +32697,17 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249) { + if (produceDiagnostics && clause.kind === 253) { 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); @@ -32273,7 +32723,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 && current.label.text === node.label.text) { + if (current.kind === 219 && 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; @@ -32299,22 +32749,20 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 70) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { + if (catchClause.variableDeclaration.type) { grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); } else if (catchClause.variableDeclaration.initializer) { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + var blockLocals = catchClause.block.locals; + if (blockLocals) { + for (var caughtName in catchClause.locals) { + var blockLocal = blockLocals[caughtName]; + if (blockLocal && (blockLocal.flags & 2) !== 0) { + grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); + } } } } @@ -32336,7 +32784,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 32768 && ts.isClassLike(type.symbol.valueDeclaration)) { + if (getObjectFlags(type) & 1 && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -32351,7 +32799,7 @@ var ts; var errorNode; if (stringIndexType && numberIndexType) { errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 65536)) { + if (!errorNode && (getObjectFlags(type) & 2)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } @@ -32367,13 +32815,13 @@ 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) { errorNode = indexDeclaration; } - else if (containingType.flags & 65536) { + else if (getObjectFlags(containingType) & 2) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } @@ -32418,7 +32866,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 === 226 || declaration.kind === 227) { if (!firstDecl) { firstDecl = declaration; } @@ -32481,7 +32929,9 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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)) { + if (baseType_1.symbol.valueDeclaration && + !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && + baseType_1.symbol.valueDeclaration.kind === 226) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -32506,8 +32956,8 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = (t.flags & 131072) ? t.target : t; - if (declaredType.flags & (32768 | 65536)) { + var declaredType = getObjectFlags(t) & 4 ? t.target : t; + if (getObjectFlags(declaredType) & 3) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -32529,7 +32979,7 @@ var ts; if (declaration && ts.getModifierFlags(declaration) & 8) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { - error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); } } } @@ -32555,7 +33005,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 === 197) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32599,7 +33049,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 || kind === 151; + return kind === 151 || kind === 152; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32637,8 +33087,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 }; @@ -32666,7 +33116,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32695,6 +33145,7 @@ var ts; function checkTypeAliasDeclaration(node) { checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } function computeEnumMemberValues(node) { @@ -32711,7 +33162,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); } @@ -32761,7 +33212,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186: + case 190: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -32772,7 +33223,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 188: + case 192: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32797,11 +33248,11 @@ var ts; return undefined; case 8: return +e.text; - case 179: + case 183: return evalConstant(e.expression); case 70: - case 174: - case 173: + case 178: + case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -32812,7 +33263,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174) { + if (e.kind === 178) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32829,7 +33280,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 173) { + else if (current.kind === 177) { current = current.expression; } else { @@ -32889,7 +33340,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 225) { + if (declaration.kind !== 229) { return false; } var enumDeclaration = declaration; @@ -32912,8 +33363,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 === 226 || + (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -32972,7 +33423,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, 226); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33015,36 +33466,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201: + case 205: 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 240: + case 241: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230: - case 231: + case 234: + case 235: 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 174: + case 223: + 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 224: + case 229: + case 225: + case 227: + case 230: + case 228: if (isGlobalAugmentation) { return; } @@ -33062,12 +33513,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 177: do { node = node.expression; } while (node.kind !== 70); @@ -33080,9 +33531,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 === 231 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 && !inAmbientExternalModule) { + error(moduleName, node.kind === 241 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33103,7 +33554,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 === 243 ? 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)); @@ -33130,7 +33581,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 237) { checkImportBinding(importClause.namedBindings); } else { @@ -33181,8 +33632,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 === 231 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -33195,7 +33646,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 === 261 || node.parent.kind === 231 || node.parent.kind === 230; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33218,8 +33669,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 === 261 ? node.parent : node.parent.parent; + if (container.kind === 230 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -33286,7 +33737,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 && declaration.kind !== 148) || + return (declaration.kind !== 225 && declaration.kind !== 149) || !!declaration.body; } } @@ -33297,118 +33748,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 230: case 226: - case 222: - case 223: - case 221: + case 227: + case 225: 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 169: + return checkIndexedAccessType(node); case 170: - return checkBindingElement(node); - case 222: - return checkClassDeclaration(node); - case 223: - return checkInterfaceDeclaration(node); - case 224: - return checkTypeAliasDeclaration(node); + return checkMappedType(node); case 225: - return checkEnumDeclaration(node); - case 226: - return checkModuleDeclaration(node); + return checkFunctionDeclaration(node); + case 204: case 231: - return checkImportDeclaration(node); - case 230: - return checkImportEqualsDeclaration(node); - case 237: - return checkExportDeclaration(node); - case 236: - return checkExportAssignment(node); - case 202: - checkGrammarStatementInAmbientContext(node); - return; + return checkBlock(node); + case 205: + return checkVariableStatement(node); + case 207: + return checkExpressionStatement(node); + case 208: + return checkIfStatement(node); + case 209: + return checkDoStatement(node); + case 210: + return checkWhileStatement(node); + case 211: + return checkForStatement(node); + case 212: + return checkForInStatement(node); + case 213: + return checkForOfStatement(node); + case 214: + case 215: + return checkBreakOrContinueStatement(node); + case 216: + return checkReturnStatement(node); + case 217: + return checkWithStatement(node); case 218: + return checkSwitchStatement(node); + case 219: + return checkLabeledStatement(node); + case 220: + return checkThrowStatement(node); + case 221: + return checkTryStatement(node); + case 223: + return checkVariableDeclaration(node); + case 174: + return checkBindingElement(node); + case 226: + return checkClassDeclaration(node); + case 227: + return checkInterfaceDeclaration(node); + case 228: + return checkTypeAliasDeclaration(node); + case 229: + return checkEnumDeclaration(node); + case 230: + return checkModuleDeclaration(node); + case 235: + return checkImportDeclaration(node); + case 234: + return checkImportEqualsDeclaration(node); + case 241: + return checkExportDeclaration(node); + case 240: + return checkExportAssignment(node); + case 206: checkGrammarStatementInAmbientContext(node); return; - case 240: + case 222: + checkGrammarStatementInAmbientContext(node); + return; + case 244: return checkMissingDeclaration(node); } } @@ -33421,17 +33877,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 184: + case 185: + case 149: case 148: - case 147: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150: case 151: + case 152: checkAccessorDeferred(node); break; - case 193: + case 197: checkClassExpressionDeferred(node); break; } @@ -33485,8 +33941,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(); @@ -33503,7 +33970,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 && node.parent.statement === node) { + if (node.parent.kind === 217 && node.parent.statement === node) { return true; } node = node.parent; @@ -33525,28 +33992,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 225: + case 229: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 193: + case 197: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 222: - case 223: + case 226: + case 227: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 180: + case 184: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33585,27 +34052,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142: - case 222: - case 223: - case 224: - case 225: + case 143: + case 226: + case 227: + case 228: + case 229: 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 === 272); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173) { + while (node.parent && node.parent.kind === 177) { node = node.parent; } - return node.parent && node.parent.kind === 195; + return node.parent && node.parent.kind === 199; } function forEachEnclosingClass(node, callback) { var result; @@ -33622,13 +34089,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 === 234) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 240) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33640,7 +34107,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 === 177) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33652,11 +34119,11 @@ var ts; default: } } - if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 240 && 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 !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 234); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -33665,7 +34132,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 195) { + if (entityName.parent.kind === 199) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33687,14 +34154,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 173) { + else if (entityName.kind === 177) { 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); @@ -33703,19 +34170,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 === 272) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 246) { + else if (entityName.parent.kind === 250) { 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 === 261) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -33731,8 +34198,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 === 174 && + node.parent.parent.kind === 172 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33743,8 +34210,8 @@ var ts; } switch (node.kind) { case 70: - case 173: - case 140: + case 177: + case 141: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -33757,18 +34224,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 === 235 || node.parent.kind === 241) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33776,7 +34243,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 174 && node.parent.argumentExpression === node) { + if (node.parent.kind === 178 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33790,7 +34257,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 254) { + if (location && location.kind === 258) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -33840,20 +34307,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 === 176 || expr.kind === 175); + if (expr.parent.kind === 213) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 188) { + if (expr.parent.kind === 192) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 253) { + if (expr.parent.kind === 257) { 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 === 175); 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); @@ -33889,9 +34356,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); } @@ -33899,6 +34366,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) { @@ -33956,7 +34427,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -33994,7 +34465,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 === 204 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34034,16 +34505,16 @@ var ts; return true; } switch (node.kind) { - case 230: - case 232: - case 233: - case 235: - case 239: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 234: + case 236: case 237: + case 239: + case 243: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 241: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236: + case 240: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -34053,7 +34524,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 !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -34104,7 +34575,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255) { + if (node.kind === 260) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -34116,7 +34587,7 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 2588672 && getSignaturesOfType(type, 0).length > 0; + return type.flags & 32768 && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); @@ -34198,9 +34669,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_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -34220,7 +34691,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 16777216); + return !!(type.flags & 96 && type.flags & 1048576); } return false; } @@ -34271,13 +34742,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 === 177) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34299,6 +34771,9 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + return undefined; + } } } return typeReferenceDirectives; @@ -34309,15 +34784,15 @@ var ts; } var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -34336,7 +34811,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256); + return ts.getDeclarationOfKind(moduleSymbol, 261); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -34366,7 +34841,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) { @@ -34435,9 +34910,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) { @@ -34472,7 +34951,7 @@ var ts; function createThenableType() { var thenPropertySymbol = createSymbol(67108864 | 4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(2097152); + var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; @@ -34484,14 +34963,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); @@ -34508,17 +34987,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 !== 229 && node.parent.kind === 226) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -34544,7 +35023,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 === 231 || node.parent.kind === 261) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -34567,10 +35046,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 === 231 || node.parent.kind === 261) { 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) { @@ -34579,11 +35058,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; @@ -34602,10 +35081,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 === 226) { 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; @@ -34617,13 +35096,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 === 226) { 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 === 231) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -34633,14 +35112,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 !== 226) { + 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 === 226 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34659,7 +35138,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; @@ -34667,7 +35146,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"); } @@ -34682,13 +35161,13 @@ var ts; } return; } - else if ((node.kind === 231 || node.kind === 230) && flags & 2) { + else if ((node.kind === 235 || node.kind === 234) && 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) { @@ -34704,37 +35183,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 146: + case 149: + case 148: + case 155: case 230: - case 237: - case 236: - case 180: - case 181: - case 143: + case 235: + case 234: + case 241: + case 240: + case 184: + case 185: + case 144: return false; default: - if (node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 231 || node.parent.kind === 261) { 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; case 225: + return nodeHasAnyModifiersExcept(node, 119); + case 226: + return nodeHasAnyModifiersExcept(node, 116); + case 227: + case 205: + case 228: + return true; + case 229: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -34747,10 +35226,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148: - case 221: - case 180: - case 181: + case 149: + case 225: + case 184: + case 185: if (!node.asteriskToken) { return false; } @@ -34812,7 +35291,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181) { + if (node.kind === 185) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34847,7 +35326,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) { @@ -34874,7 +35353,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 === 198) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -34944,19 +35423,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 === 192 && 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 === 225 || + node.kind === 184 || + node.kind === 149); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -34981,42 +35460,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 === 259) { + continue; } - if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { + var name_28 = prop.name; + if (name_28.kind === 142) { + checkGrammarComputedPropertyName(name_28); + } + if (prop.kind === 258 && !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 === 257 || prop.kind === 258) { 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; } @@ -35026,18 +35508,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); } } } @@ -35046,19 +35528,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 === 251) { 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 === 252 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -35067,7 +35549,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220) { + if (forInOrOfStatement.initializer.kind === 224) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35075,20 +35557,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 + var diagnostic = forInOrOfStatement.kind === 212 ? 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 === 212 ? 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 === 212 ? 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); @@ -35112,11 +35594,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); } @@ -35135,10 +35617,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); } } @@ -35153,7 +35635,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172) { + if (node.parent.kind === 176) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -35169,10 +35651,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 === 227) { 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); } } @@ -35183,9 +35665,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215: + case 219: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 210 + var isMisplacedContinueLabel = node.kind === 214 && !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); @@ -35193,8 +35675,8 @@ var ts; return false; } break; - case 214: - if (node.kind === 211 && !node.label) { + case 218: + if (node.kind === 215 && !node.label) { return false; } break; @@ -35207,13 +35689,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 + var message = node.kind === 215 ? 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 === 215 ? 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); @@ -35223,9 +35705,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 === 173 || node.name.kind === 172) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35235,11 +35717,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 190 && 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 !== 212 && node.parent.parent.kind !== 213) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35296,15 +35778,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204: - case 205: - case 206: - case 213: - case 207: case 208: case 209: + case 210: + case 217: + case 211: + case 212: + case 213: return false; - case 215: + case 219: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35359,7 +35841,7 @@ var ts; return true; } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 227) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35367,7 +35849,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; } @@ -35380,13 +35862,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 === 227 || + node.kind === 228 || + node.kind === 235 || + node.kind === 234 || + node.kind === 241 || + node.kind === 240 || + node.kind === 233 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35395,7 +35877,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 === 205) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35414,7 +35896,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { 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); @@ -35453,49 +35935,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[182] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196] = [ + _a[200] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197] = [ + _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225] = [ + _a[229] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227] = [ + _a[231] = [ { name: "statements", test: ts.isStatement } ], - _a[230] = [ + _a[234] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241] = [ + _a[245] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255] = [ + _a[260] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -35508,41 +35990,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 <= 171)) { return initial; } var result = initial; switch (node.kind) { - case 199: - case 202: - case 194: - case 218: - case 287: + case 203: + case 206: + case 198: + case 222: + case 292: 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); @@ -35551,17 +36033,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: @@ -35569,46 +36043,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 172: + case 173: result = ts.reduceLeft(node.elements, f, result); break; - case 170: + case 174: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 171: + case 175: result = ts.reduceLeft(node.elements, f, result); break; - case 172: + case 176: result = ts.reduceLeft(node.properties, f, result); break; - case 173: + case 177: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174: + case 178: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175: + case 179: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176: + case 180: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177: + case 181: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180: + case 184: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35616,117 +36098,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181: + case 185: 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 189: + case 195: + case 196: + case 201: + result = reduceNode(node.expression, f, result); + break; + case 190: + case 191: result = reduceNode(node.operand, f, result); break; - case 188: + case 192: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189: + case 193: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190: + case 194: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193: + case 197: 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 199: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 198: + case 202: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 200: + case 204: result = ts.reduceLeft(node.statements, f, result); break; - case 201: + case 205: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203: + case 207: result = reduceNode(node.expression, f, result); break; - case 204: + case 208: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205: + case 209: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206: - case 213: + case 210: + case 217: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207: + case 211: 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 212: + case 213: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212: case 216: + case 220: result = reduceNode(node.expression, f, result); break; - case 214: + case 218: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215: + case 219: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217: + case 221: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219: + case 223: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220: + case 224: result = ts.reduceLeft(node.declarations, f, result); break; - case 221: + case 225: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35735,7 +36217,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222: + case 226: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35743,89 +36225,92 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228: + case 232: result = ts.reduceLeft(node.clauses, f, result); break; - case 231: + case 235: 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 236: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233: + case 237: result = reduceNode(node.name, f, result); break; - case 234: case 238: + case 242: result = ts.reduceLeft(node.elements, f, result); break; - case 235: case 239: + case 243: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236: + case 240: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237: + case 241: 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 246: 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 247: + case 248: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245: + case 249: result = reduceNode(node.tagName, f, result); break; - case 246: + case 250: 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); - 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); + break; + case 253: + result = reduceNode(node.expression, f, result); + case 254: + result = ts.reduceLeft(node.statements, f, result); + break; + case 255: + result = ts.reduceLeft(node.types, f, result); + break; + case 256: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; - case 253: + case 257: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254: + case 258: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; - case 256: + case 259: + result = reduceNode(node.expression, f, result); + break; + case 261: result = ts.reduceLeft(node.statements, f, result); break; - case 288: + case 293: result = reduceNode(node.expression, f, result); break; default: @@ -35850,6 +36335,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -35892,6 +36378,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) { @@ -35928,178 +36415,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 <= 171)) { 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 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())); + case 198: case 222: + 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 172: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 173: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 174: + 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 175: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 176: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 177: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 178: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 179: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 180: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 181: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 183: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 184: + 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 185: + 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 186: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 187: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 189: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 192: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 190: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 191: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 193: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 194: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 195: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 196: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 197: + 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 199: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 204: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 205: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 207: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 208: + 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 209: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 210: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 211: + 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 212: + 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 213: + 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 214: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 215: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 216: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 217: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 218: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 219: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 220: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 221: + 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 223: + 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 224: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 225: + 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 226: 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)); - case 234: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 235: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + 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 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.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); 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.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 238: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 239: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + case 240: + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 241: + 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 242: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); 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)); - case 245: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 246: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSelfClosingElement(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.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 250: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 251: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxSpreadAttribute(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.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), 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.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 255: + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 256: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 257: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 258: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 259: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 261: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 288: + case 293: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -36158,7 +36647,7 @@ var ts; return 0; } else if (node.transformFlags & 536870912) { - return node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); + return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind); } else { var subtreeFlags = aggregateTransformFlagsForSubtree(node); @@ -36174,68 +36663,17 @@ var ts; function aggregateTransformFlagsForChildNode(transformFlags, child) { return transformFlags | aggregateTransformFlagsForNode(child); } - function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 && kind <= 167) { - 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 150: - 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: - case 153: - case 154: - case 223: - case 224: - return -3; - case 172: - return 539110741; - default: - return 536874325; - } - } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function () { }; + : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function () { }; + : ts.noop; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function () { }; + : ts.noop; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36254,7 +36692,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)) { @@ -36273,7 +36711,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); } @@ -36291,11 +36729,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); @@ -36308,12 +36749,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) { @@ -36343,33 +36787,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); } @@ -36400,17 +36850,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172) { + if (target.kind === 176) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171) { + else if (target.kind === 175) { 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) { @@ -36418,16 +36868,79 @@ 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 === 257 || p.kind === 258) { + if (!transformRest || + p.transformFlags & 8388608 || + (p.kind === 257 && p.initializer.transformFlags & 8388608)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 258 ? p : p.initializer || propName; + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && + p.kind === 259 && + 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 === 198) { + 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) { @@ -36435,8 +36948,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 !== 198) { + if (e.kind !== 196) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36445,42 +36958,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 === 173) { + 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) { @@ -36523,12 +37124,6 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; - var TypeScriptSubstitutionFlags; - (function (TypeScriptSubstitutionFlags) { - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; - })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36539,14 +37134,14 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(174); + context.enableSubstitution(177); + context.enableSubstitution(178); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -36572,7 +37167,7 @@ var ts; return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 256) { + if (node.kind === 261) { return visitSourceFile(node); } else if (node.transformFlags & 1) { @@ -36588,13 +37183,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231: + case 235: return visitImportDeclaration(node); - case 230: + case 234: return visitImportEqualsDeclaration(node); - case 236: + case 240: return visitExportAssignment(node); - case 237: + case 241: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -36604,11 +37199,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 === 241 || + node.kind === 235 || + node.kind === 236 || + (node.kind === 234 && + node.moduleReference.kind === 245)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36624,21 +37219,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 203: 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); @@ -36653,78 +37257,81 @@ 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 171: + case 155: + case 145: + case 228: + 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 227: + return ts.createNotEmittedStatement(node); case 226: - return visitModuleDeclaration(node); + return visitClassDeclaration(node); + case 197: + return visitClassExpression(node); + case 255: + return visitHeritageClause(node); + case 199: + return visitExpressionWithTypeArguments(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessor(node); + case 152: + return visitSetAccessor(node); + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 183: + return visitParenthesizedExpression(node); + case 182: + case 200: + return visitAssertionExpression(node); + case 179: + return visitCallExpression(node); + case 180: + return visitNewExpression(node); + case 201: + return visitNonNullExpression(node); + case 229: + return visitEnumDeclaration(node); + case 205: + return visitVariableStatement(node); + case 223: + return visitVariableDeclaration(node); case 230: + return visitModuleDeclaration(node); + case 234: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36733,15 +37340,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 256: - case 228: - case 227: - case 200: + case 261: + case 232: + case 231: + case 204: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222: - case 221: + case 226: + case 225: if (ts.hasModifier(node, 2)) { break; } @@ -36751,10 +37358,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(); @@ -36765,10 +37373,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; } @@ -36795,66 +37403,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); @@ -36887,7 +37488,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); @@ -36929,7 +37530,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -36963,7 +37564,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; } @@ -37036,12 +37637,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; @@ -37119,37 +37720,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); @@ -37160,7 +37757,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); } @@ -37178,13 +37775,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))); } } } @@ -37192,58 +37789,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 === 226 + || kind === 197 + || 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 226: + case 197: + 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 { @@ -37291,20 +37888,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 171: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -37318,16 +37915,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; @@ -37351,10 +37948,13 @@ var ts; return serializedUnion; } } - case 159: case 160: + case 168: + case 169: + case 170: + case 161: case 118: - case 166: + case 167: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37396,15 +37996,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); } } @@ -37478,7 +38078,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); @@ -37491,27 +38091,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]; @@ -37524,12 +38124,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; } @@ -37576,7 +38176,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)); @@ -37598,7 +38198,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); @@ -37634,39 +38234,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) { @@ -37701,9 +38294,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; @@ -37718,32 +38313,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 === 229) { + 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)) { @@ -37753,25 +38353,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) { @@ -37786,7 +38387,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227) { + if (body.kind === 231) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37809,13 +38410,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 227) { + if (body.kind !== 231) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226) { + if (moduleDeclaration.body.kind === 230) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -37835,7 +38436,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 233) { + if (node.kind === 237) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -37887,8 +38488,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 { @@ -37913,36 +38514,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); @@ -37952,40 +38537,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() { @@ -38005,15 +38571,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(254); - context.enableEmitNotification(226); + context.enableSubstitution(258); + context.enableEmitNotification(230); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226; + return ts.getOriginalNode(node).kind === 230; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 229; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38038,14 +38604,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; @@ -38054,9 +38620,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 173: + case 177: return substitutePropertyAccessExpression(node); - case 174: + case 178: return substituteElementAccessExpression(node); } return node; @@ -38084,11 +38650,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 !== 261) { + var substitute = (applicableSubstitutions & 2 && container.kind === 230) || + (applicableSubstitutions & 8 && container.kind === 229); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38159,11 +38725,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242: + case 246: return visitJsxElement(node, false); - case 243: + case 247: return visitJsxSelfClosingElement(node, false); - case 248: + case 252: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38174,11 +38740,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 248: + case 252: return visitJsxExpression(node); - case 242: + case 246: return visitJsxElement(node, true); - case 243: + case 247: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38208,7 +38774,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); } @@ -38230,7 +38796,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 248) { + else if (node.kind === 252) { return visitJsxExpression(node); } else { @@ -38295,16 +38861,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242) { + if (node.kind === 246) { return getTagName(node.openingElement); } else { - var name_31 = node.tagName; - if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { - return ts.createLiteral(name_31.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_31); + return ts.createExpressionFromEntityName(name_34); } } } @@ -38581,12 +39147,165 @@ 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 176: + return visitObjectLiteralExpression(node); + case 192: + return visitBinaryExpression(node); + case 223: + return visitVariableDeclaration(node); + case 213: + return visitForOfStatement(node); + case 172: + case 173: + return node; + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + 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 === 259) { + 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 === 257) { + 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 !== 176) { + 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 === 172 && + !!(declaration.name.transformFlags & 8388608); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 176 && + 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 === 172 && + !!(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 ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); @@ -38609,10 +39328,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; @@ -38621,15 +39340,15 @@ var ts; switch (node.kind) { case 119: return undefined; - case 185: + case 189: return visitAwaitExpression(node); - case 148: + case 149: return visitMethodDeclaration(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); - case 181: + case 185: return visitArrowFunction(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38694,9 +39413,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 === 185; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; @@ -38739,12 +39459,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; @@ -38752,23 +39474,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(179); + context.enableSubstitution(177); + context.enableSubstitution(178); + context.enableEmitNotification(226); context.enableEmitNotification(149); + context.enableEmitNotification(151); + context.enableEmitNotification(152); + context.enableEmitNotification(150); } } function substituteExpression(node) { switch (node.kind) { - case 173: + case 177: return substitutePropertyAccessExpression(node); - case 174: + case 178: return substituteElementAccessExpression(node); - case 175: + case 179: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -38811,11 +39533,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 - || kind === 149 - || kind === 148 + return kind === 226 || kind === 150 - || kind === 151; + || kind === 149 + || kind === 151 + || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38861,10 +39583,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 { @@ -38873,7 +39595,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188: + case 192: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38916,28 +39638,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var ES2015SubstitutionFlags; - (function (ES2015SubstitutionFlags) { - ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -38955,6 +39655,7 @@ var ts; var enclosingFunction; var enclosingNonArrowFunction; var enclosingNonAsyncFunctionBody; + var isInConstructorWithCapturedSuper; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -38984,11 +39685,14 @@ var ts; var savedCurrentParent = currentParent; var savedCurrentNode = currentNode; var savedConvertedLoopState = convertedLoopState; + var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; if (ts.nodeStartsNewLexicalEnvironment(node)) { + isInConstructorWithCapturedSuper = false; convertedLoopState = undefined; } onBeforeVisitNode(node); var visited = f(node); + isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; convertedLoopState = savedConvertedLoopState; enclosingFunction = savedEnclosingFunction; enclosingNonArrowFunction = savedEnclosingNonArrowFunction; @@ -39000,16 +39704,25 @@ var ts; currentNode = savedCurrentNode; return visited; } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + } + function isReturnVoidStatementInConstructorWithCapturedSuper(node) { + return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + } function shouldCheckNode(node) { - return (node.transformFlags & 256) !== 0 || - node.kind === 215 || + return (node.transformFlags & 1024) !== 0 || + node.kind === 219 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { - if (shouldCheckNode(node)) { + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512) { + else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -39028,14 +39741,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212: + case 216: + node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201: + case 205: return visitVariableStatement(node); - case 214: + case 218: return visitSwitchStatement(node); - case 211: - case 210: + case 215: + case 214: return visitBreakOrContinueStatement(node); case 98: return visitThisKeyword(node); @@ -39047,74 +39761,76 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83: - return node; - case 222: + case 114: + return undefined; + case 226: return visitClassDeclaration(node); - case 193: + case 197: return visitClassExpression(node); - case 143: + case 144: return visitParameter(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 181: + case 185: return visitArrowFunction(node); - case 180: + case 184: return visitFunctionExpression(node); - case 219: + case 223: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 220: + case 224: return visitVariableDeclarationList(node); - case 215: + case 219: return visitLabeledStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); case 209: + return visitDoStatement(node); + case 210: + return visitWhileStatement(node); + case 211: + return visitForStatement(node); + case 212: + return visitForInStatement(node); + case 213: return visitForOfStatement(node); - case 203: + case 207: return visitExpressionStatement(node); - case 172: - return visitObjectLiteralExpression(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 171: - return visitArrayLiteralExpression(node); - case 175: - return visitCallExpression(node); case 176: - return visitNewExpression(node); + return visitObjectLiteralExpression(node); + case 256: + return visitCatchClause(node); + case 258: + return visitShorthandPropertyAssignment(node); + case 175: + return visitArrayLiteralExpression(node); case 179: + return visitCallExpression(node); + case 180: + return visitNewExpression(node); + case 183: return visitParenthesizedExpression(node, true); - case 188: + case 192: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 177: + case 181: return visitTaggedTemplateExpression(node); - case 190: + case 194: return visitTemplateExpression(node); - case 191: + case 195: return visitYieldExpression(node); case 96: return visitSuperKeyword(); - case 191: + case 195: return ts.visitEachChild(node, visitor, context); - case 148: + case 149: return visitMethodDeclaration(node); - case 256: + case 261: return visitSourceFileNode(node); - case 201: + case 205: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39129,7 +39845,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181) { + if (currentNode.kind !== 185) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39137,14 +39853,14 @@ var ts; } } switch (currentNode.kind) { - case 201: + case 205: enclosingVariableStatement = currentNode; break; - case 220: - case 219: - case 170: - case 168: - case 169: + case 224: + case 223: + case 174: + case 172: + case 173: break; default: enclosingVariableStatement = undefined; @@ -39172,7 +39888,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181) { + if (enclosingFunction && enclosingFunction.kind === 185) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39192,13 +39908,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 211 ? 2 : 4; + var jump = node.kind === 215 ? 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 === 215) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39208,7 +39924,7 @@ var ts; } } else { - if (node.kind === 211) { + if (node.kind === 215) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39238,26 +39954,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); @@ -39267,7 +39983,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); } @@ -39288,7 +40004,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); @@ -39303,13 +40019,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); } @@ -39332,8 +40048,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); @@ -39341,7 +40057,10 @@ var ts; statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); + var body = saveStateAndInvoke(constructor, function (constructor) { + isInConstructorWithCapturedSuper = superCaptureStatus === 1; + return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); + }); ts.addRange(statements, body); } if (extendsClauseElement @@ -39357,17 +40076,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 212) { + if (statement.kind === 216) { return true; } - else if (statement.kind === 204) { + else if (statement.kind === 208) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200) { + else if (statement.kind === 204) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39378,7 +40097,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0; } @@ -39387,7 +40106,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -39396,7 +40115,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 === 207 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39405,7 +40124,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; } @@ -39422,111 +40141,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_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_32)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_32, 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 203: 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); @@ -39591,7 +40232,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 262144) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39602,80 +40243,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 !== 185) { 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 183: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 188: + case 192: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39683,9 +40266,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 179: + case 183: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 188: + case 192: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39731,7 +40314,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); @@ -39750,8 +40333,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 - && enclosingBlockScopeContainer.kind !== 209 + && enclosingBlockScopeContainer.kind !== 212 + && enclosingBlockScopeContainer.kind !== 213 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39813,68 +40396,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; @@ -39882,8 +40404,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; } @@ -39938,11 +40460,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207: - case 208: - case 209: + case 211: + case 212: + case 213: var initializer = node.initializer; - if (initializer && initializer.kind === 220) { + if (initializer && initializer.kind === 224) { loopInitializer = initializer; } break; @@ -39981,7 +40503,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; @@ -39989,9 +40511,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) { @@ -40049,7 +40571,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 + statements.push(currentParent.kind === 219 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -40148,7 +40670,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 }); @@ -40161,20 +40683,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 257: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254: + case 258: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148: + case 149: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -40204,6 +40726,19 @@ var ts; } return expression; } + function visitCatchClause(node) { + ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + function addStatementToStartOfBlock(block, statement) { + var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); + return ts.updateBlock(block, [statement].concat(transformedStatements)); + } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); @@ -40231,7 +40766,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 { @@ -40248,35 +40783,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 !== 175 ? 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) { @@ -40349,7 +40884,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 175 + && currentParent.kind !== 179 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40358,7 +40893,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); @@ -40383,13 +40918,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(185); + context.enableEmitNotification(184); + context.enableEmitNotification(225); } } function onSubstituteNode(emitContext, node) { @@ -40414,10 +40949,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170: - case 222: - case 225: - case 219: + case 174: + case 226: + case 229: + case 223: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40449,28 +40984,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_33 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_33, emitFlags); - } - return name_33; - } - 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) { @@ -40482,11 +40997,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 !== 207) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { return false; } var callTarget = statementExpression.expression; @@ -40494,7 +41009,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 !== 196) { return false; } var expression = callArgument.expression; @@ -40505,51 +41020,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var OpCode; - (function (OpCode) { - OpCode[OpCode["Nop"] = 0] = "Nop"; - OpCode[OpCode["Statement"] = 1] = "Statement"; - OpCode[OpCode["Assign"] = 2] = "Assign"; - OpCode[OpCode["Break"] = 3] = "Break"; - OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; - OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; - OpCode[OpCode["Yield"] = 6] = "Yield"; - OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; - OpCode[OpCode["Return"] = 8] = "Return"; - OpCode[OpCode["Throw"] = 9] = "Throw"; - OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; - })(OpCode || (OpCode = {})); - var BlockAction; - (function (BlockAction) { - BlockAction[BlockAction["Open"] = 0] = "Open"; - BlockAction[BlockAction["Close"] = 1] = "Close"; - })(BlockAction || (BlockAction = {})); - var CodeBlockKind; - (function (CodeBlockKind) { - CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; - CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; - CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; - CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; - CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; - })(CodeBlockKind || (CodeBlockKind = {})); - var ExceptionBlockState; - (function (ExceptionBlockState) { - ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; - ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; - ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; - ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; - })(ExceptionBlockState || (ExceptionBlockState = {})); - var Instruction; - (function (Instruction) { - Instruction[Instruction["Next"] = 0] = "Next"; - Instruction[Instruction["Throw"] = 1] = "Throw"; - Instruction[Instruction["Return"] = 2] = "Return"; - Instruction[Instruction["Break"] = 3] = "Break"; - Instruction[Instruction["Yield"] = 4] = "Yield"; - Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; - Instruction[Instruction["Catch"] = 6] = "Catch"; - Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; - })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40595,7 +41065,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; @@ -40610,10 +41080,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 { @@ -40622,13 +41092,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205: + case 209: return visitDoStatement(node); - case 206: + case 210: return visitWhileStatement(node); - case 214: + case 218: return visitSwitchStatement(node); - case 215: + case 219: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40636,30 +41106,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); - case 150: case 151: + case 152: return visitAccessorDeclaration(node); - case 201: + case 205: return visitVariableStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); case 211: - return visitBreakStatement(node); - case 210: - return visitContinueStatement(node); + return visitForStatement(node); case 212: + return visitForInStatement(node); + case 215: + return visitBreakStatement(node); + case 214: + return visitContinueStatement(node); + case 216: 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 { @@ -40669,21 +41139,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188: + case 192: return visitBinaryExpression(node); - case 189: + case 193: return visitConditionalExpression(node); - case 191: + case 195: return visitYieldExpression(node); - case 171: - return visitArrayLiteralExpression(node); - case 172: - return visitObjectLiteralExpression(node); - case 174: - return visitElementAccessExpression(node); case 175: - return visitCallExpression(node); + return visitArrayLiteralExpression(node); case 176: + return visitObjectLiteralExpression(node); + case 178: + return visitElementAccessExpression(node); + case 179: + return visitCallExpression(node); + case 180: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40691,9 +41161,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40796,7 +41266,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; } @@ -40850,10 +41320,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173: + case 177: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174: + case 178: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -41045,35 +41515,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); - case 206: - return transformAndEmitWhileStatement(node); + return transformAndEmitBlock(node); case 207: - return transformAndEmitForStatement(node); + return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitForInStatement(node); + return transformAndEmitIfStatement(node); + case 209: + return transformAndEmitDoStatement(node); case 210: - return transformAndEmitContinueStatement(node); + return transformAndEmitWhileStatement(node); case 211: - return transformAndEmitBreakStatement(node); + return transformAndEmitForStatement(node); case 212: - return transformAndEmitReturnStatement(node); - case 213: - return transformAndEmitWithStatement(node); + return transformAndEmitForInStatement(node); case 214: - return transformAndEmitSwitchStatement(node); + return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitLabeledStatement(node); + return transformAndEmitBreakStatement(node); case 216: - return transformAndEmitThrowStatement(node); + return transformAndEmitReturnStatement(node); case 217: + return transformAndEmitWithStatement(node); + case 218: + return transformAndEmitSwitchStatement(node); + case 219: + return transformAndEmitLabeledStatement(node); + case 220: + return transformAndEmitThrowStatement(node); + case 221: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41357,7 +41827,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 === 254 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -41367,7 +41837,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 === 253) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -41458,7 +41928,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; @@ -41488,9 +41958,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_34) { - var clone_8 = ts.getMutableClone(name_34); + 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; @@ -41789,7 +42259,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -41798,7 +42268,7 @@ var ts; } return expression; } - return ts.createNode(194); + return ts.createOmittedExpression(); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41886,7 +42356,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() { @@ -42157,8 +42627,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(253); + context.enableSubstitution(177); + context.enableSubstitution(257); return transformSourceFile; function transformSourceFile(node) { return node; @@ -42198,6 +42668,841 @@ 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 234: + return undefined; + case 240: + 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(192); + context.enableSubstitution(190); + context.enableSubstitution(191); + context.enableEmitNotification(261); + 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 === 241 && 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 !== 241) { + 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 235: + if (!entry.importClause) { + break; + } + case 234: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 241: + 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 235: + return visitImportDeclaration(node); + case 234: + return visitImportEqualsDeclaration(node); + case 241: + return undefined; + case 240: + 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 === 261 + || (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 === 205) { + 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 237: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238: + 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 205: + return visitVariableStatement(node); + case 225: + return visitFunctionDeclaration(node); + case 226: + return visitClassDeclaration(node); + case 211: + return visitForStatement(node); + case 212: + return visitForInStatement(node); + case 213: + return visitForOfStatement(node); + case 209: + return visitDoStatement(node); + case 210: + return visitWhileStatement(node); + case 219: + return visitLabeledStatement(node); + case 217: + return visitWithStatement(node); + case 218: + return visitSwitchStatement(node); + case 232: + return visitCaseBlock(node); + case 253: + return visitCaseClause(node); + case 254: + return visitDefaultClause(node); + case 221: + return visitTryStatement(node); + case 256: + return visitCatchClause(node); + case 204: + return visitBlock(node); + case 294: + return visitMergeDeclarationMarker(node); + case 295: + 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 === 192) { + 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 === 261; + } + 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 === 261) { + 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 192: + return substituteBinaryExpression(node); + case 190: + case 191: + 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 === 191 + ? 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 === 191) { + 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 === 261) { + 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 = {}, @@ -42217,48 +43522,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(192); + context.enableSubstitution(190); + context.enableSubstitution(191); + context.enableSubstitution(258); + context.enableEmitNotification(261); + 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; @@ -42275,77 +43572,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 235: return visitImportDeclaration(node); - case 230: + case 234: return visitImportEqualsDeclaration(node); - case 237: + case 241: return visitExportDeclaration(node); - case 236: + case 240: return visitExportAssignment(node); - case 201: + case 205: return visitVariableStatement(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 222: + case 226: return visitClassDeclaration(node); - case 203: - return visitExpressionStatement(node); + case 294: + return visitMergeDeclarationMarker(node); + case 295: + 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 = []; @@ -42358,43 +43683,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); @@ -42408,7 +43750,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); } @@ -42424,195 +43766,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_35 = names_1[_i]; - addExportMemberAssignments(statements, name_35); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_36 = node.name; - if (ts.isIdentifier(name_36)) { - names.push(name_36); - } - } - 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 === 205) { + 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 237: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238: + 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_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 === 256) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + if (node.kind === 261) { + 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); @@ -42620,6 +44015,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); } @@ -42644,946 +44042,88 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 188: + case 192: return substituteBinaryExpression(node); - case 187: - case 186: + case 191: + case 190: 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 === 261) { + 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) { - 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_3 = exportedNames; _i < exportedNames_3.length; _i++) { + var exportName = exportedNames_3[_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 === 191 + ? 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); } - 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_37 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), 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; } ts.transformModule = transformModule; })(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_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_38 = node.name || ts.getGeneratedNameForNode(node); - var isAsync = ts.hasModifier(node, 256); - var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_38); - } - 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_39 = getDeclarationName(originalNode); - if (originalNode.kind === 225) { - hoistVariableDeclaration(name_39); - } - return [ - node, - createExportStatement(name_39, name_39) - ]; - } - 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 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) { var moduleTransformerMap = ts.createMap((_a = {}, _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, @@ -43593,21 +44133,18 @@ var ts; _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); - var SyntaxKindFeatureFlags; - (function (SyntaxKindFeatureFlags) { - SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; - SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; - })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); 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); } @@ -43618,6 +44155,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); } @@ -43627,7 +44165,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289); + var enabledSyntaxKindFeatures = new Array(296); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -43914,7 +44452,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 !== 292 && (emitFlags & 512) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -43927,7 +44465,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 + if (node.kind !== 292 && (emitFlags & 1024) === 0 && end >= 0) { emitPos(end); @@ -44071,7 +44609,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287; + var isEmittedNode = node.kind !== 292; var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -44085,7 +44623,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 220) { + if (node.kind === 224) { declarationListContainerEnd = end; } } @@ -44313,7 +44851,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? ts.noop : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -44357,7 +44895,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 === 235); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -44428,10 +44966,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219) { + if (declaration.kind === 223) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { + else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -44442,7 +44980,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 === 235) { moduleElementEmitInfo.isVisible = true; } else { @@ -44450,12 +44988,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 230) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 230) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -44568,43 +45106,49 @@ 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 171: return writeTextOfNode(currentText, type); - case 195: + case 199: 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 emitIndexedAccessType(type); + case 170: + return emitMappedType(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) { @@ -44612,22 +45156,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 === 234 ? 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 === 177); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44673,6 +45217,42 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitIndexedAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } + function emitMappedType(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + writeEntityName(node.typeParameter.name); + write(" in "); + emitType(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emitType(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + enclosingDeclaration = prevEnclosingDeclaration; + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -44701,9 +45281,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; } } } @@ -44747,10 +45327,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 || - (node.parent.kind === 256 && isCurrentFileExternalModule)) { + else if (node.kind === 234 || + (node.parent.kind === 261 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -44759,7 +45339,7 @@ var ts; }); } else { - if (node.kind === 231) { + if (node.kind === 235) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44777,30 +45357,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 205: + return writeVariableStatement(node); + case 227: + return writeInterfaceDeclaration(node); case 226: - return writeModuleDeclaration(node); + return writeClassDeclaration(node); + case 228: + return writeTypeAliasDeclaration(node); + case 229: + return writeEnumDeclaration(node); case 230: + return writeModuleDeclaration(node); + case 234: return writeImportEqualsDeclaration(node); - case 231: + case 235: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 256) { + if (node.parent.kind === 261) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -44808,7 +45388,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 223 && !noDeclare) { + else if (node.kind !== 227 && !noDeclare) { write("declare "); } } @@ -44858,7 +45438,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 237) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44881,7 +45461,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 233) { + if (node.importClause.namedBindings.kind === 237) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44898,13 +45478,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; var moduleSpecifier; - if (parent.kind === 230) { + if (parent.kind === 234) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226) { + else if (parent.kind === 230) { moduleSpecifier = parent.name; } else { @@ -44972,7 +45552,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227) { + while (node.body && node.body.kind !== 231) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -45042,7 +45622,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) { @@ -45052,15 +45632,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 { @@ -45070,31 +45650,31 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 222: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223: + case 227: 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 === 226) { 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 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -45131,7 +45711,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 226) { 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; @@ -45211,17 +45791,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 223 || 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)) { @@ -45234,14 +45814,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219) { + if (node.kind === 223) { 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 ? @@ -45249,7 +45829,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 === 226) { 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 : @@ -45275,7 +45855,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 !== 198) { elements.push(element); } } @@ -45341,7 +45921,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; @@ -45354,7 +45934,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 @@ -45363,7 +45943,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 : @@ -45409,17 +45989,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221) { + if (node.kind === 225) { 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 === 225) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149) { + else if (node.kind === 150) { write("constructor"); } else { @@ -45439,15 +46019,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; @@ -45458,20 +46038,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; @@ -45485,23 +46065,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 ? @@ -45509,7 +46089,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 === 226) { 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 : @@ -45522,7 +46102,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221: + case 225: 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 : @@ -45554,9 +46134,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)) { @@ -45572,22 +46152,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 ? @@ -45595,7 +46175,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 === 226) { 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 : @@ -45607,7 +46187,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 225: 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 : @@ -45618,12 +46198,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 172) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 173) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -45634,10 +46214,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194) { + if (bindingElement.kind === 198) { write(" "); } - else if (bindingElement.kind === 170) { + else if (bindingElement.kind === 174) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45659,39 +46239,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221: - case 226: - case 230: - case 223: - case 222: - case 224: case 225: + case 230: + case 234: + case 227: + case 226: + case 228: + case 229: return emitModuleElement(node, isModuleElementVisible(node)); - case 201: + case 205: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231: + case 235: return emitModuleElement(node, !node.importClause); - case 237: + case 241: 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 260: return emitEnumMemberDeclaration(node); - case 236: + case 240: return emitExportAssignment(node); - case 256: + case 261: return emitSourceFile(node); } } @@ -45746,12 +46326,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { @@ -45759,6 +46333,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};"; @@ -45791,6 +46366,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -45924,7 +46500,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 256: + case 261: return emitSourceFile(node); } } @@ -45962,7 +46538,6 @@ var ts; case 123: case 124: case 125: - case 126: case 127: case 128: case 129: @@ -45976,182 +46551,191 @@ 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); - case 198: - return emitTemplateSpan(node); + return emitParenthesizedType(node); case 199: - return emitSemicolonClassElement(); - case 200: - return emitBlock(node); - case 201: - return emitVariableStatement(node); + return emitExpressionWithTypeArguments(node); + case 167: + return emitThisType(); + case 168: + return emitTypeOperator(node); + case 169: + return emitIndexedAccessType(node); + case 170: + return emitMappedType(node); + case 171: + return emitLiteralType(node); + case 172: + return emitObjectBindingPattern(node); + case 173: + return emitArrayBindingPattern(node); + case 174: + return emitBindingElement(node); case 202: - return emitEmptyStatement(); + return emitTemplateSpan(node); case 203: - return emitExpressionStatement(node); + return emitSemicolonClassElement(); case 204: - return emitIfStatement(node); + return emitBlock(node); case 205: - return emitDoStatement(node); + return emitVariableStatement(node); case 206: - return emitWhileStatement(node); + return emitEmptyStatement(); case 207: - return emitForStatement(node); + return emitExpressionStatement(node); case 208: - return emitForInStatement(node); + return emitIfStatement(node); case 209: - return emitForOfStatement(node); + return emitDoStatement(node); case 210: - return emitContinueStatement(node); + return emitWhileStatement(node); case 211: - return emitBreakStatement(node); + return emitForStatement(node); case 212: - return emitReturnStatement(node); + return emitForInStatement(node); case 213: - return emitWithStatement(node); + return emitForOfStatement(node); case 214: - return emitSwitchStatement(node); + return emitContinueStatement(node); case 215: - return emitLabeledStatement(node); + return emitBreakStatement(node); case 216: - return emitThrowStatement(node); + return emitReturnStatement(node); case 217: - return emitTryStatement(node); + return emitWithStatement(node); case 218: - return emitDebuggerStatement(node); + return emitSwitchStatement(node); case 219: - return emitVariableDeclaration(node); + return emitLabeledStatement(node); case 220: - return emitVariableDeclarationList(node); + return emitThrowStatement(node); case 221: - return emitFunctionDeclaration(node); + return emitTryStatement(node); case 222: - return emitClassDeclaration(node); + return emitDebuggerStatement(node); case 223: - return emitInterfaceDeclaration(node); + return emitVariableDeclaration(node); case 224: - return emitTypeAliasDeclaration(node); + return emitVariableDeclarationList(node); case 225: - return emitEnumDeclaration(node); + return emitFunctionDeclaration(node); case 226: - return emitModuleDeclaration(node); + return emitClassDeclaration(node); case 227: - return emitModuleBlock(node); + return emitInterfaceDeclaration(node); case 228: - return emitCaseBlock(node); + return emitTypeAliasDeclaration(node); + case 229: + return emitEnumDeclaration(node); case 230: - return emitImportEqualsDeclaration(node); + return emitModuleDeclaration(node); case 231: - return emitImportDeclaration(node); + return emitModuleBlock(node); case 232: - return emitImportClause(node); - case 233: - return emitNamespaceImport(node); + return emitCaseBlock(node); case 234: - return emitNamedImports(node); + return emitImportEqualsDeclaration(node); case 235: - return emitImportSpecifier(node); + return emitImportDeclaration(node); case 236: - return emitExportAssignment(node); + return emitImportClause(node); case 237: - return emitExportDeclaration(node); + return emitNamespaceImport(node); case 238: - return emitNamedExports(node); + return emitNamedImports(node); case 239: - return emitExportSpecifier(node); + return emitImportSpecifier(node); case 240: - return; + return emitExportAssignment(node); case 241: + return emitExportDeclaration(node); + case 242: + return emitNamedExports(node); + case 243: + return emitExportSpecifier(node); + case 244: + return; + case 245: 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); case 248: - return emitJsxExpression(node); + return emitJsxOpeningElement(node); case 249: - return emitCaseClause(node); + return emitJsxClosingElement(node); case 250: - return emitDefaultClause(node); + return emitJsxAttribute(node); case 251: - return emitHeritageClause(node); + return emitJsxSpreadAttribute(node); case 252: - return emitCatchClause(node); + return emitJsxExpression(node); case 253: - return emitPropertyAssignment(node); + return emitCaseClause(node); case 254: - return emitShorthandPropertyAssignment(node); + return emitDefaultClause(node); case 255: + return emitHeritageClause(node); + case 256: + return emitCatchClause(node); + case 257: + return emitPropertyAssignment(node); + case 258: + return emitShorthandPropertyAssignment(node); + case 259: + return emitSpreadAssignment(node); + case 260: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -46176,63 +46760,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); case 175: - return emitCallExpression(node); + return emitArrayLiteralExpression(node); case 176: - return emitNewExpression(node); + return emitObjectLiteralExpression(node); case 177: - return emitTaggedTemplateExpression(node); + return emitPropertyAccessExpression(node); case 178: - return emitTypeAssertionExpression(node); + return emitElementAccessExpression(node); case 179: - return emitParenthesizedExpression(node); + return emitCallExpression(node); case 180: - return emitFunctionExpression(node); + return emitNewExpression(node); case 181: - return emitArrowFunction(node); + return emitTaggedTemplateExpression(node); case 182: - return emitDeleteExpression(node); + return emitTypeAssertionExpression(node); case 183: - return emitTypeOfExpression(node); + return emitParenthesizedExpression(node); case 184: - return emitVoidExpression(node); + return emitFunctionExpression(node); case 185: - return emitAwaitExpression(node); + return emitArrowFunction(node); case 186: - return emitPrefixUnaryExpression(node); + return emitDeleteExpression(node); case 187: - return emitPostfixUnaryExpression(node); + return emitTypeOfExpression(node); case 188: - return emitBinaryExpression(node); + return emitVoidExpression(node); case 189: - return emitConditionalExpression(node); + return emitAwaitExpression(node); case 190: - return emitTemplateExpression(node); + return emitPrefixUnaryExpression(node); case 191: - return emitYieldExpression(node); + return emitPostfixUnaryExpression(node); case 192: - return emitSpreadElementExpression(node); + return emitBinaryExpression(node); case 193: - return emitClassExpression(node); + return emitConditionalExpression(node); case 194: - return; + return emitTemplateExpression(node); + case 195: + return emitYieldExpression(node); case 196: - return emitAsExpression(node); + return emitSpreadExpression(node); case 197: + return emitClassExpression(node); + case 198: + return; + case 200: + return emitAsExpression(node); + case 201: return emitNonNullExpression(node); - case 242: + case 246: return emitJsxElement(node); - case 243: + case 247: return emitJsxSelfClosingElement(node); - case 288: + case 293: return emitPartiallyEmittedExpression(node); } } @@ -46336,7 +46920,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); } @@ -46421,6 +47005,39 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitIndexedAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } + function emitMappedType(node) { + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + emit(node.typeParameter.name); + write(" in "); + emit(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emit(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -46584,7 +47201,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 186 + return operand.kind === 190 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -46628,7 +47245,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -46696,7 +47313,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 204) { + if (node.elseStatement.kind === 208) { write(" "); emit(node.elseStatement); } @@ -46758,7 +47375,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220) { + if (node.kind === 224) { emit(node); } else { @@ -46987,7 +47604,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226) { + while (body.kind === 230) { write("."); emit(body.name); body = body.body; @@ -47206,6 +47823,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); @@ -47275,10 +47898,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) { @@ -47601,7 +48231,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 && ts.nodeIsSynthesized(node)) { + while (node.kind === 183 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -47658,21 +48288,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; } } } @@ -47710,17 +48340,17 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 226: - case 225: + case 230: + case 229: return generateNameForModuleOrEnum(node); - case 231: - case 237: + case 235: + case 241: return generateNameForImportOrExportDeclaration(node); - case 221: - case 222: - case 236: + case 225: + case 226: + case 240: return generateNameForExportDefault(); - case 193: + case 197: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -47790,72 +48420,10 @@ var ts; } } ts.emitFiles = emitFiles; - var ListFormat; - (function (ListFormat) { - ListFormat[ListFormat["None"] = 0] = "None"; - ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; - ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; - ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; - ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; - ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; - ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; - ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; - ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; - ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; - ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; - })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.0"; + ts.version = "2.2.0"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -48070,11 +48638,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; @@ -48088,7 +48656,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(); @@ -48101,7 +48669,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; }; @@ -48163,6 +48738,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -48170,12 +48746,13 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); return program; function getCommonSourceDirectory() { - if (typeof commonSourceDirectory === "undefined") { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + if (commonSourceDirectory === undefined) { + var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } else { - commonSourceDirectory = computeCommonSourceDirectory(files); + commonSourceDirectory = computeCommonSourceDirectory(emittedFiles); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { commonSourceDirectory += ts.directorySeparator; @@ -48194,26 +48771,85 @@ 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; } var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.moduleResolution !== options.moduleResolution) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx) || - (oldOptions.allowJs !== options.allowJs) || - (oldOptions.rootDir !== options.rootDir) || - (oldOptions.configFilePath !== options.configFilePath) || - (oldOptions.baseUrl !== options.baseUrl) || - (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || - !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || - !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || - !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !ts.equalOwnProperties(oldOptions.paths, options.paths)) { + if (ts.changesAffectModuleResolution(oldOptions, options)) { return false; } ts.Debug.assert(!oldProgram.structureIsReused); @@ -48254,40 +48890,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; @@ -48303,11 +48943,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)); } @@ -48384,6 +49027,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) { @@ -48403,183 +49052,170 @@ 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 181: - case 221: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + case 152: + case 184: + case 225: + case 185: + case 225: + case 223: + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } + } + switch (node.kind) { + case 234: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 240: + if (node.isExportEquals) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; } break; - case 201: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; + case 255: + 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 219: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; + case 227: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 230: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 228: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 229: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 182: + 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 226: + case 149: + case 148: + case 150: + case 151: + case 152: + case 184: + case 225: + case 185: + case 225: + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + case 205: + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 205); } 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 179: + case 180: + case 199: + 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); } }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -48596,9 +49232,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); } @@ -48617,14 +49250,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(235); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -48636,12 +49273,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 235: + case 234: + case 241: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -48653,13 +49291,16 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226: + case 230: 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++) { @@ -48683,7 +49324,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("', '") + "'"]; @@ -48744,7 +49385,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); } @@ -48816,9 +49457,11 @@ var ts; } else { if (previousResolution) { - var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); - if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { + var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); + if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + } } saveResolution = false; } @@ -48853,23 +49496,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--; @@ -48879,7 +49530,6 @@ var ts; else { file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -49033,7 +49683,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) { @@ -49048,10 +49706,15 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + 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)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); } else { emitFilesSeen.set(emitFilePath, true); @@ -49059,12 +49722,33 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, message) { + function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + 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) { @@ -49138,6 +49822,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", @@ -49325,6 +50014,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, @@ -49481,7 +50171,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 @@ -49626,7 +50317,11 @@ var ts; i++; break; case "boolean": - options[opt.name] = true; + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } break; case "string": options[opt.name] = args[i] || ""; @@ -49744,9 +50439,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": @@ -49754,12 +50449,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") { @@ -49768,10 +50463,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); } } } @@ -49885,6 +50580,9 @@ var ts; if (ts.hasProperty(json, "files")) { if (ts.isArray(json["files"])) { fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); @@ -49921,7 +50619,11 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; } var _b; } @@ -49957,9 +50659,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; } @@ -50090,14 +50790,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; @@ -50118,6 +50817,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); @@ -50539,10 +51251,13 @@ var ts; startTimerForHandlingDirectoryChanges(); } function startTimerForHandlingDirectoryChanges() { - if (timerHandleForDirectoryChanges) { - clearTimeout(timerHandleForDirectoryChanges); + if (!ts.sys.setTimeout || !ts.sys.clearTimeout) { + return; } - timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250); + if (timerHandleForDirectoryChanges) { + ts.sys.clearTimeout(timerHandleForDirectoryChanges); + } + timerHandleForDirectoryChanges = ts.sys.setTimeout(directoryChangeHandler, 250); } function directoryChangeHandler() { var parsedCommandLine = parseConfigFile(); @@ -50554,10 +51269,13 @@ var ts; } } function startTimerForRecompilation() { - if (timerHandleForRecompilation) { - clearTimeout(timerHandleForRecompilation); + if (!ts.sys.setTimeout || !ts.sys.clearTimeout) { + return; } - timerHandleForRecompilation = setTimeout(recompile, 250); + if (timerHandleForRecompilation) { + ts.sys.clearTimeout(timerHandleForRecompilation); + } + timerHandleForRecompilation = ts.sys.setTimeout(recompile, 250); } function recompile() { timerHandleForRecompilation = undefined; @@ -50636,17 +51354,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) { @@ -50765,5 +51483,3 @@ if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnviron ts.sys.tryEnableSourceMapsForHost(); } ts.executeCommandLine(ts.sys.args); - -//# sourceMappingURL=tsc.js.map diff --git a/lib/tsserver.js b/lib/tsserver.js index be6578b0762..a426c38658c 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -20,462 +20,19 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - 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["QualifiedName"] = 140] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; - 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["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["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; - 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["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; - 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["ExternalModuleReference"] = 241] = "ExternalModuleReference"; - 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["CaseClause"] = 249] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; - 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["SyntaxList"] = 286] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; - SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - 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; - (function (NodeFlags) { - NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Let"] = 1] = "Let"; - NodeFlags[NodeFlags["Const"] = 2] = "Const"; - NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; - NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; - NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; - 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["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; - NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; - NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; - (function (ModifierFlags) { - ModifierFlags[ModifierFlags["None"] = 0] = "None"; - ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; - ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; - ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; - ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; - ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; - ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; - ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; - ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; - ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; - ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; - ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; - ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; - ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; - })(ts.ModifierFlags || (ts.ModifierFlags = {})); - var ModifierFlags = ts.ModifierFlags; - (function (JsxFlags) { - JsxFlags[JsxFlags["None"] = 0] = "None"; - JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; - JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; - (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; - (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; - (function (FlowFlags) { - FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; - FlowFlags[FlowFlags["Start"] = 2] = "Start"; - FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; - FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; - FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; - FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; - FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; - FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["Label"] = 12] = "Label"; - FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; - })(ts.FlowFlags || (ts.FlowFlags = {})); - var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } 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; - (function (TypeFormatFlags) { - TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; - TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; - TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; - TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; - TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; - TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; - TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; - TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; - TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; - TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - (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; - (function (TypePredicateKind) { - TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; - TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; - })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); - var TypePredicateKind = ts.TypePredicateKind; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -488,179 +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; - (function (SymbolFlags) { - SymbolFlags[SymbolFlags["None"] = 0] = "None"; - SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; - SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; - SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; - SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; - SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; - SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; - SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; - SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; - SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; - SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; - SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; - SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; - SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; - SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; - SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; - SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; - SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; - SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; - SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; - SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; - SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; - SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; - SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; - SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; - SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; - SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; - SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; - SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; - SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; - SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; - SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; - SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; - SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; - SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; - SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; - SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; - SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; - SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; - SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; - SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; - NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; - NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; - NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; - (function (TypeFlags) { - TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["Void"] = 1024] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 4096] = "Null"; - TypeFlags[TypeFlags["Never"] = 8192] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 32768] = "Class"; - TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 524288] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; - TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; - TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; - TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; - TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; - TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; - TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; - TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; - TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; - (function (SignatureKind) { - SignatureKind[SignatureKind["Call"] = 0] = "Call"; - SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; - (function (IndexKind) { - IndexKind[IndexKind["String"] = 0] = "String"; - IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; - (function (SpecialPropertyAssignmentKind) { - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; - })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); - var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; + })(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"; @@ -668,266 +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; - (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; - (function (NewLineKind) { - NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; - NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; - })(ts.NewLineKind || (ts.NewLineKind = {})); - var NewLineKind = ts.NewLineKind; - (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; - (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; - (function (LanguageVariant) { - LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; - LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; - })(ts.LanguageVariant || (ts.LanguageVariant = {})); - var LanguageVariant = ts.LanguageVariant; - (function (DiagnosticStyle) { - DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; - DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; - })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); - var DiagnosticStyle = ts.DiagnosticStyle; - (function (WatchDirectoryFlags) { - WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; - WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; - })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); - var WatchDirectoryFlags = ts.WatchDirectoryFlags; - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; - CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; - CharacterCodes[CharacterCodes["space"] = 32] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; - CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; - CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; - CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; - CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; - CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; - CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; - CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["j"] = 106] = "j"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["B"] = 66] = "B"; - CharacterCodes[CharacterCodes["C"] = 67] = "C"; - CharacterCodes[CharacterCodes["D"] = 68] = "D"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["G"] = 71] = "G"; - CharacterCodes[CharacterCodes["H"] = 72] = "H"; - CharacterCodes[CharacterCodes["I"] = 73] = "I"; - CharacterCodes[CharacterCodes["J"] = 74] = "J"; - CharacterCodes[CharacterCodes["K"] = 75] = "K"; - CharacterCodes[CharacterCodes["L"] = 76] = "L"; - CharacterCodes[CharacterCodes["M"] = 77] = "M"; - CharacterCodes[CharacterCodes["N"] = 78] = "N"; - CharacterCodes[CharacterCodes["O"] = 79] = "O"; - CharacterCodes[CharacterCodes["P"] = 80] = "P"; - CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; - CharacterCodes[CharacterCodes["R"] = 82] = "R"; - CharacterCodes[CharacterCodes["S"] = 83] = "S"; - CharacterCodes[CharacterCodes["T"] = 84] = "T"; - CharacterCodes[CharacterCodes["U"] = 85] = "U"; - CharacterCodes[CharacterCodes["V"] = 86] = "V"; - CharacterCodes[CharacterCodes["W"] = 87] = "W"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; - (function (TransformFlags) { - TransformFlags[TransformFlags["None"] = 0] = "None"; - TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; - 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["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["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - 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["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["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["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; - })(ts.TransformFlags || (ts.TransformFlags = {})); - var TransformFlags = ts.TransformFlags; - (function (EmitFlags) { - EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; - EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; - EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; - EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; - EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; - EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; - EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; - EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; - EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; - EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; - EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; - EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; - EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; - EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; - EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; - EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; - EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; - EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; - EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; - EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; - EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; - EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.EmitFlags || (ts.EmitFlags = {})); - var EmitFlags = ts.EmitFlags; - (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; + })(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) { @@ -990,12 +137,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - (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; var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { @@ -1060,12 +201,6 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; - (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; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -1078,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++) { @@ -1337,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); } @@ -1373,6 +520,41 @@ var ts; return result; } ts.deduplicate = deduplicate; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function changesAffectModuleResolution(oldOptions, newOptions) { + return !oldOptions || + (oldOptions.module !== newOptions.module) || + (oldOptions.moduleResolution !== newOptions.moduleResolution) || + (oldOptions.noResolve !== newOptions.noResolve) || + (oldOptions.target !== newOptions.target) || + (oldOptions.noLib !== newOptions.noLib) || + (oldOptions.jsx !== newOptions.jsx) || + (oldOptions.allowJs !== newOptions.allowJs) || + (oldOptions.rootDir !== newOptions.rootDir) || + (oldOptions.configFilePath !== newOptions.configFilePath) || + (oldOptions.baseUrl !== newOptions.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) || + !arrayIsEqualTo(oldOptions.lib, newOptions.lib) || + !arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) || + !equalOwnProperties(oldOptions.paths, newOptions.paths); + } + ts.changesAffectModuleResolution = changesAffectModuleResolution; function compact(array) { var result; if (array) { @@ -1391,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++) { @@ -1400,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) { @@ -1427,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] @@ -1439,17 +655,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; + function replaceElement(array, index, value) { + var result = array.slice(0); + result[index] = value; + return result; } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value, comparer) { + ts.replaceElement = replaceElement; + 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 @@ -1683,6 +899,12 @@ var ts; return Array.isArray ? Array.isArray(value) : value instanceof Array; } ts.isArray = isArray; + function noop() { } + ts.noop = noop; + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; function memoize(callback) { var value; return function () { @@ -1798,6 +1020,17 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText + }; + } + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; function chainDiagnosticMessages(details, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -2190,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); } @@ -2217,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); } @@ -2345,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; } @@ -2413,14 +1670,6 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; - (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; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -2471,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); } @@ -2509,13 +1754,6 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; - (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; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2627,6 +1865,36 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + var ext = tryGetExtensionFromPath(path); + if (ext !== undefined) { + return ext; + } + Debug.fail("File " + path + " has unknown extension."); + } + ts.extensionFromPath = extensionFromPath; + function tryGetExtensionFromPath(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; + } + } + ts.tryGetExtensionFromPath = tryGetExtensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2900,11 +2168,6 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } - var FileSystemEntryKind; - (function (FileSystemEntryKind) { - FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; - FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; - })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2926,6 +2189,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, @@ -2935,7 +2199,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 { @@ -2943,7 +2207,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); } }; @@ -2958,7 +2222,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 }; @@ -3035,7 +2299,9 @@ var ts; } catch (e) { } - } + }, + setTimeout: setTimeout, + clearTimeout: clearTimeout }; return nodeSystem; } @@ -3153,7 +2419,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." }, @@ -3263,7 +2529,6 @@ var ts; Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, @@ -3381,14 +2646,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}'" }, @@ -3428,7 +2693,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" }, @@ -3466,8 +2731,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." }, @@ -3479,7 +2742,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." }, @@ -3501,9 +2764,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." }, @@ -3550,6 +2811,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." }, @@ -3573,6 +2841,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." }, @@ -3604,6 +2873,10 @@ 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." }, + An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, 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}'." }, @@ -3703,6 +2976,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." }, @@ -3786,7 +3060,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." }, @@ -3823,11 +3097,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." }, @@ -3836,7 +3115,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." }, @@ -3883,6 +3163,8 @@ var ts; Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, @@ -3890,4175 +3172,11 @@ var ts; Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, 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; -(function (ts) { - function trace(host) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - ts.trace = trace; - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - ts.createResolvedModule = createResolvedModule; - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - 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)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - 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 { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_1 = ts.getDirectoryPath(currentDirectory); - if (parent_1 === currentDirectory) { - break; - } - currentDirectory = parent_1; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - 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]; - 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) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = 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); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - 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]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - 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); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - 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); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - 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; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - 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); - } - } - 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) { - 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; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - 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) { - 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); - } - 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); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - 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); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, 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); - }); - } - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(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; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); - } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(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; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); - } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; - function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); - } - function loadModuleFromNodeModulesWorker(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; - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - 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 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) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - return referencedSourceFile; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - return undefined; - } - containingDirectory = parentPath; - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - var declaration = declarations_1[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str_1 = ""; - var writeText = function (text) { return str_1 += text; }; - return { - string: function () { return str_1; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = ts.createMap(); - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { - if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); - } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; - } - ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; - } - ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; - } - ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { - if (names.length !== newResolutions.length) { - return false; - } - for (var i = 0; i < names.length; i++) { - var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; - var changed = oldResolution - ? !newResolution || !comparer(oldResolution, newResolution) - : newResolution; - if (changed) { - return true; - } - } - return false; - } - ts.hasChangesInResolutions = hasChangesInResolutions; - function containsParseError(node) { - aggregateChildData(node); - return (node.flags & 2097152) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; - } - node.flags |= 4194304; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function isStatementWithLocals(node) { - switch (node.kind) { - case 200: - case 228: - case 207: - case 208: - case 209: - return true; - } - return false; - } - ts.isStatementWithLocals = isStatementWithLocals; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = ts.getLineStarts(sourceFile); - var lineIndex = line; - var sourceText = sourceFile.text; - if (lineIndex + 1 === lineStarts.length) { - return sourceText.length - 1; - } - else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function nodeIsMissing(node) { - if (node === undefined) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { - if (nodeIsMissing(node)) { - return node.pos; - } - if (isJSDocNode(node)) { - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); - } - if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { - return getTokenPosOfNode(node.jsDocComments[0]); - } - if (node.kind === 286 && 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; - } - ts.isJSDocNode = isJSDocNode; - function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; - } - ts.isJSDocTag = isJSDocTag; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 15: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; - } - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclaration(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function isAmbientModule(node) { - return node && node.kind === 226 && - (node.name.kind === 9 || isGlobalScopeAugmentation(node)); - } - ts.isAmbientModule = isAmbientModule; - function isShorthandAmbientModuleSymbol(moduleSymbol) { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); - } - ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; - function isShorthandAmbientModule(node) { - return node.kind === 226 && (!node.body); - } - function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 226 || - isFunctionLike(node); - } - ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; - function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); - } - ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; - function isExternalModuleAugmentation(node) { - if (!node || !isAmbientModule(node)) { - return false; - } - switch (node.parent.kind) { - case 256: - return ts.isExternalModule(node.parent); - case 227: - return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); - } - return false; - } - 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 150: - case 151: - case 221: - case 180: - case 181: - return true; - case 200: - return parentNode && !isFunctionLike(parentNode); - } - return false; - } - ts.isBlockScope = isBlockScope; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 219 && - declaration.parent && - declaration.parent.kind === 252; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForArrowFunction(sourceFile, node) { - var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200) { - var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; - if (startLine < endLine) { - return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); - } - } - return ts.createTextSpanFromBounds(pos, node.end); - } - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 256: - 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 225: - case 255: - case 221: - case 180: - case 148: - case 150: - case 151: - case 224: - errorNode = node.name; - break; - case 181: - return getErrorSpanForArrowFunction(sourceFile, node); - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalOrCommonJsModule(file) { - return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; - } - ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; - function isDeclarationFile(file) { - return file.isDeclarationFile; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 225 && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); - } - ts.isConst = isConst; - function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1); - } - ts.isLet = isLet; - function isSuperCall(n) { - return n.kind === 175 && n.expression.kind === 96; - } - ts.isSuperCall = isSuperCall; - function isPrologueDirective(node) { - return node.kind === 203 && node.expression.kind === 9; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJsDocComments(node, sourceFileOfNode) { - return getJsDocCommentsFromText(node, sourceFileOfNode.text); - } - ts.getJsDocComments = getJsDocComments; - function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 || - node.kind === 142 || - node.kind === 180 || - node.kind === 181) ? - ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 42 && - text.charCodeAt(comment.pos + 3) !== 47; - } - } - ts.getJsDocCommentsFromText = getJsDocCommentsFromText; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isPartOfTypeNode(node) { - if (155 <= node.kind && node.kind <= 167) { - return true; - } - switch (node.kind) { - case 118: - case 131: - case 133: - case 121: - case 134: - case 136: - case 128: - return true; - case 104: - return node.parent.kind !== 184; - case 195: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 140 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 173 && 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: - case 98: - var parent_2 = node.parent; - if (parent_2.kind === 159) { - return false; - } - if (155 <= parent_2.kind && parent_2.kind <= 167) { - return true; - } - switch (parent_2.kind) { - case 195: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 142: - return node === parent_2.constraint; - case 146: - case 145: - case 143: - case 219: - return node === parent_2.type; - case 221: - case 180: - case 181: - case 149: - case 148: - case 147: - case 150: - case 151: - return node === parent_2.type; - case 152: - case 153: - case 154: - return node === parent_2.type; - case 178: - return node === parent_2.type; - case 175: - case 176: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 177: - return false; - } - } - return false; - } - ts.isPartOfTypeNode = isPartOfTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 212: - return visitor(node); - case 228: - case 200: - case 204: - case 205: - case 206: - case 207: - case 208: - case 209: - case 213: - case 214: - case 249: - case 250: - case 215: - case 217: - case 252: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 191: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 225: - case 223: - case 226: - case 224: - case 222: - case 193: - return; - default: - if (isFunctionLike(node)) { - var name_4 = node.name; - if (name_4 && name_4.kind === 141) { - traverse(name_4.expression); - return; - } - } - else if (!isPartOfTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 170: - case 255: - case 143: - case 253: - case 146: - case 145: - case 254: - case 219: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 150 || node.kind === 151); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 222 || node.kind === 193); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); - } - ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { - switch (kind) { - case 149: - case 180: - case 221: - case 181: - case 148: - case 147: - case 150: - case 151: - case 152: - case 153: - case 154: - case 157: - case 158: - return true; - } - return false; - } - ts.isFunctionLikeKind = isFunctionLikeKind; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 148: - case 147: - case 149: - case 150: - case 151: - case 221: - case 180: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 207: - case 208: - case 209: - case 205: - case 206: - return true; - case 215: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - ts.isIterationStatement = isIterationStatement; - function isFunctionBlock(node) { - return node && node.kind === 200 && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 148 && node.parent.kind === 172; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 && - (node.parent.kind === 172 || - node.parent.kind === 193); - } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; - function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1; - } - ts.isIdentifierTypePredicate = isIdentifierTypePredicate; - function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0; - } - ts.isThisTypePredicate = isThisTypePredicate; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 141: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 181: - if (!includeArrowFunctions) { - continue; - } - case 221: - case 180: - case 226: - case 146: - case 145: - case 148: - case 147: - case 149: - case 150: - case 151: - case 152: - case 153: - case 154: - case 225: - case 256: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, stopOnFunctions) { - while (true) { - node = node.parent; - if (!node) { - return node; - } - switch (node.kind) { - case 141: - node = node.parent; - break; - case 221: - case 180: - case 181: - if (!stopOnFunctions) { - continue; - } - case 146: - case 145: - case 148: - case 147: - case 149: - case 150: - case 151: - return node; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 || func.kind === 181) { - var prev = func; - var parent_3 = func.parent; - while (parent_3.kind === 179) { - prev = parent_3; - parent_3 = parent_3.parent; - } - if (parent_3.kind === 175 && parent_3.expression === prev) { - return parent_3; - } - } - } - ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; - function isSuperProperty(node) { - var kind = node.kind; - return (kind === 173 || kind === 174) - && 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; - } - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function isCallLikeExpression(node) { - switch (node.kind) { - case 175: - case 176: - case 177: - case 144: - return true; - default: - return false; - } - } - ts.isCallLikeExpression = isCallLikeExpression; - function getInvokedExpression(node) { - if (node.kind === 177) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 222: - return true; - case 146: - return node.parent.kind === 222; - case 150: - case 151: - case 148: - return node.body !== undefined - && node.parent.kind === 222; - case 143: - return node.parent.body !== undefined - && (node.parent.kind === 149 - || node.parent.kind === 148 - || node.parent.kind === 151) - && node.parent.parent.kind === 222; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - return node.decorators !== undefined - && nodeCanBeDecorated(node); - } - ts.nodeIsDecorated = nodeIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 222: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148: - case 151: - 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) { - return parent.tagName === node; - } - return false; - } - ts.isJSXTagName = isJSXTagName; - function isPartOfExpression(node) { - switch (node.kind) { - case 98: - case 96: - case 94: - 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 181: - case 184: - case 182: - case 183: - case 186: - case 187: - case 188: - case 189: - case 192: - case 190: - case 12: - case 194: - case 242: - case 243: - case 191: - case 185: - return true; - case 140: - while (node.parent.kind === 140) { - node = node.parent; - } - return node.parent.kind === 159 || isJSXTagName(node); - case 70: - if (node.parent.kind === 159 || isJSXTagName(node)) { - return true; - } - case 8: - case 9: - case 98: - var parent_4 = node.parent; - switch (parent_4.kind) { - case 219: - case 143: - case 146: - case 145: - case 255: - case 253: - case 170: - 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: - var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || - forInStatement.expression === node; - case 178: - case 196: - return node === parent_4.expression; - case 198: - return node === parent_4.expression; - case 141: - return node === parent_4.expression; - case 144: - case 248: - case 247: - return true; - case 195: - return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); - default: - if (isPartOfExpression(parent_4)) { - return true; - } - } - } - return false; - } - ts.isPartOfExpression = isPartOfExpression; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind === 241; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind !== 241; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function isSourceFileJavaScript(file) { - return isInJavaScriptFile(file); - } - ts.isSourceFileJavaScript = isSourceFileJavaScript; - function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); - } - ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 175 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); - } - ts.isRequireCall = isRequireCall; - function isSingleOrDoubleQuote(charCode) { - return charCode === 39 || charCode === 34; - } - ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219) { - var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180; - } - return false; - } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; - function getSpecialPropertyAssignmentKind(expression) { - if (!isInJavaScriptFile(expression)) { - return 0; - } - if (expression.kind !== 188) { - return 0; - } - var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { - return 0; - } - var lhs = expr.left; - if (lhs.expression.kind === 70) { - var lhsId = lhs.expression; - if (lhsId.text === "exports") { - return 1; - } - else if (lhsId.text === "module" && lhs.name.text === "exports") { - return 2; - } - } - else if (lhs.expression.kind === 98) { - return 4; - } - else if (lhs.expression.kind === 173) { - var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { - var innerPropertyAccessIdentifier = innerPropertyAccess.expression; - if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { - return 1; - } - if (innerPropertyAccess.name.text === "prototype") { - return 3; - } - } - } - return 0; - } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; - function getExternalModuleName(node) { - if (node.kind === 231) { - return node.moduleSpecifier; - } - if (node.kind === 230) { - var reference = node.moduleReference; - if (reference.kind === 241) { - return reference.expression; - } - } - if (node.kind === 237) { - return node.moduleSpecifier; - } - if (node.kind === 226 && node.name.kind === 9) { - return node.name; - } - } - ts.getExternalModuleName = getExternalModuleName; - function getNamespaceDeclarationNode(node) { - if (node.kind === 230) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { - return importClause.namedBindings; - } - } - ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; - function isDefaultImport(node) { - return node.kind === 231 - && node.importClause - && !!node.importClause.name; - } - ts.isDefaultImport = isDefaultImport; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 143: - case 148: - case 147: - case 254: - case 253: - case 146: - case 145: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 269 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 271; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind, checkParentVariableStatement) { - if (!node) { - return undefined; - } - var jsDocTags = getJSDocTags(node, checkParentVariableStatement); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { - var tag = jsDocTags_1[_i]; - if (tag.kind === kind) { - return tag; - } - } - } - function append(previous, additional) { - if (additional) { - if (!previous) { - previous = []; - } - for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { - var x = additional_1[_i]; - previous.push(x); - } - } - return previous; - } - function getJSDocComments(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); - } - ts.getJSDocComments = getJSDocComments; - function getJSDocTags(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { - var result = []; - for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { - var doc = docs_1[_i]; - if (doc.tags) { - result.push.apply(result, doc.tags); - } - } - return result; - }, function (tags) { return tags; }); - } - function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { - var result = undefined; - if (checkParentVariableStatement) { - var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && - (node.parent).initializer === node && - node.parent.parent.parent.kind === 201; - var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201; - 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) { - 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.operatorToken.kind === 57 && - parent_5.parent.kind === 203; - if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); - } - var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; - if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 143) { - var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); - if (paramTags) { - result = append(result, getTags(paramTags)); - } - } - } - if (isVariableLike(node) && node.initializer) { - result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); - } - if (node.jsDocComments) { - if (result) { - result = append(result, getDocs(node.jsDocComments)); - } - else { - return getDocs(node.jsDocComments); - } - } - return result; - } - function getJSDocParameterTag(param, checkParentVariableStatement) { - var func = param.parent; - 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; }); - if (paramTags && 0 <= i && i < paramTags.length) { - return [paramTags[i]]; - } - } - else if (param.name.kind === 70) { - var name_5 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_5; }); - if (paramTags) { - return paramTags; - } - } - else { - return undefined; - } - } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); - } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 70) { - var parameterName = parameter.name.text; - var jsDocTags = getJSDocTags(parameter.parent, true); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { - var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { - var parameterTag = tag; - if (parameterTag.parameterName.text === parameterName) { - return parameterTag; - } - } - } - } - return undefined; - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function hasDeclaredRestParameter(s) { - return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); - } - ts.hasDeclaredRestParameter = hasDeclaredRestParameter; - function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; - } - } - return isDeclaredRestParam(node); - } - ts.isRestParameter = isRestParameter; - function isDeclaredRestParam(node) { - return node && node.dotDotDotToken !== undefined; - } - ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 179) { - node = node.parent; - } - while (true) { - var parent_6 = node.parent; - if (parent_6.kind === 171 || parent_6.kind === 192) { - node = parent_6; - continue; - } - 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; - } - } - ts.isAssignmentTarget = isAssignmentTarget; - function isNodeDescendantOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - ts.isNodeDescendantOf = isNodeDescendantOf; - function isInAmbientContext(node) { - while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 235 || parent.kind === 239) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 141 && - 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 151: - case 255: - case 253: - case 173: - return parent.name === node; - case 140: - if (parent.right === node) { - while (parent.kind === 140) { - parent = parent.parent; - } - return parent.kind === 159; - } - return false; - case 170: - case 235: - return parent.propertyName === node; - case 239: - 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); - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - return isEntityNameExpression(node.expression); - } - ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { - var clause = clauses_1[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.test(comment)) { - if (isNoDefaultLibRegEx.test(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); - if (refMatchResult || refLibResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: (refMatchResult || refLibResult)[3] - }, - isNoDefaultLib: false, - isTypeReferenceDirective: !!refLibResult - }; - } - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 71 <= token && token <= 139; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(kind) { - return kind === 9 || kind === 8; - } - ts.isStringOrNumericLiteral = isStringOrNumericLiteral; - function hasDynamicName(declaration) { - return declaration.name && isDynamicName(declaration.name); - } - ts.hasDynamicName = hasDynamicName; - function isDynamicName(name) { - return name.kind === 141 && - !isStringOrNumericLiteral(name.expression.kind) && - !isWellKnownSymbolSyntactically(name.expression); - } - ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { - return name.text; - } - if (name.kind === 141) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - else if (nameExpression.kind === 9 || nameExpression.kind === 8) { - return nameExpression.text; - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isPushOrUnshiftIdentifier(node) { - return node.text === "push" || node.text === "unshift"; - } - ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; - function isModifierKind(token) { - switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 129: - case 114: - return true; - } - return false; - } - ts.isModifierKind = isModifierKind; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 143; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 170) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(node) { - var kind = node.kind; - return kind === 149 - || kind === 180 - || kind === 221 - || kind === 181 - || kind === 148 - || kind === 150 - || kind === 151 - || kind === 226 - || kind === 256; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } - } - return node; - } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; - } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; - function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; - function getOriginalNodeId(node) { - node = getOriginalNode(node); - return node ? ts.getNodeId(node) : 0; - } - ts.getOriginalNodeId = getOriginalNodeId; - (function (Associativity) { - Associativity[Associativity["Left"] = 0] = "Left"; - Associativity[Associativity["Right"] = 1] = "Right"; - })(ts.Associativity || (ts.Associativity = {})); - var Associativity = ts.Associativity; - function getExpressionAssociativity(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; - return getOperatorAssociativity(expression.kind, operator, hasArguments); - } - ts.getExpressionAssociativity = getExpressionAssociativity; - function getOperatorAssociativity(kind, operator, hasArguments) { - switch (kind) { - case 176: - return hasArguments ? 0 : 1; - case 186: - case 183: - case 184: - case 182: - case 185: - case 189: - case 191: - return 1; - case 188: - switch (operator) { - case 39: - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 1; - } - } - return 0; - } - ts.getOperatorAssociativity = getOperatorAssociativity; - function getExpressionPrecedence(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; - return getOperatorPrecedence(expression.kind, operator, hasArguments); - } - ts.getExpressionPrecedence = getExpressionPrecedence; - function getOperator(expression) { - if (expression.kind === 188) { - return expression.operatorToken.kind; - } - else if (expression.kind === 186 || expression.kind === 187) { - return expression.operator; - } - else { - return expression.kind; - } - } - ts.getOperator = getOperator; - function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { - switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - 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 182: - case 185: - return 15; - case 188: - switch (operatorKind) { - case 50: - case 51: - return 15; - case 39: - case 38: - case 40: - case 41: - return 14; - case 36: - case 37: - return 13; - case 44: - case 45: - case 46: - return 12; - case 26: - case 29: - case 28: - case 30: - case 91: - case 92: - return 11; - case 31: - case 33: - case 32: - case 34: - return 10; - case 47: - return 9; - case 49: - return 8; - case 48: - return 7; - case 52: - return 6; - case 53: - return 5; - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 3; - case 25: - return 0; - default: - return -1; - } - case 189: - return 4; - case 191: - return 2; - case 192: - return 1; - default: - return -1; - } - } - ts.getOperatorPrecedence = getOperatorPrecedence; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = ts.createMap(); - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }); - function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; - } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output; - var indent; - var lineStart; - var lineCount; - var linePos; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function reset() { - output = ""; - indent = 0; - lineStart = true; - lineCount = 0; - linePos = 0; - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(text, node) { - write(getTextOfNodeFromSourceText(text, node)); - } - reset(); - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; }, - isAtStartOfLine: function () { return lineStart; }, - reset: reset - }; - } - ts.createTextWriter = createTextWriter; - function getResolvedExternalModuleName(host, file) { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); - } - ts.getResolvedExternalModuleName = getResolvedExternalModuleName; - function getExternalModuleNameFromDeclaration(host, resolver, declaration) { - var file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { - return undefined; - } - return getResolvedExternalModuleName(host, file); - } - ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; - function getExternalModuleNameFromPath(host, fileName) { - var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); - var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); - return ts.removeFileExtension(relativePath); - } - ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getDeclarationEmitOutputFilePath(sourceFile, host) { - var options = host.getCompilerOptions(); - var outputDir = options.declarationDir || options.outDir; - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } - ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getSourceFilesToEmit(host, targetSourceFile) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); - } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, isNonDeclarationFile); - } - } - ts.getSourceFilesToEmit = getSourceFilesToEmit; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { - if (sourceFiles.length) { - var jsFilePath = options.outFile || options.out; - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); - } - } - } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; - function getSourceMapFilePath(jsFilePath, options) { - return options.sourceMap ? jsFilePath + ".map" : undefined; - } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); - } - } - } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - var commonSourceDirectory = host.getCommonSourceDirectory(); - var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; - sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; - } - ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 149 && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); - return accessor.parameters[hasThis ? 1 : 0].type; - } - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function getThisParameter(signature) { - if (signature.parameters.length) { - var thisParameter = signature.parameters[0]; - if (parameterIsThisKeyword(thisParameter)) { - return thisParameter; - } - } - } - ts.getThisParameter = getThisParameter; - function parameterIsThisKeyword(parameter) { - return isThisIdentifier(parameter.name); - } - ts.parameterIsThisKeyword = parameterIsThisKeyword; - function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); - } - ts.isThisIdentifier = isThisIdentifier; - function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; - } - ts.identifierIsThisKeyword = identifierIsThisKeyword; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 150) { - getAccessor = accessor; - } - else if (accessor.kind === 151) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 150 || member.kind === 151) - && hasModifier(member, 32) === hasModifier(accessor, 32)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 150 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 151 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { - emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { - if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { - if (pos !== commentPos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; - function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { - if (comments && comments.length > 0) { - if (leadingSeparator) { - writer.write(" "); - } - var emitInterveningSeparator = false; - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - if (emitInterveningSeparator) { - writer.write(" "); - emitInterveningSeparator = false; - } - writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else { - emitInterveningSeparator = true; - } - } - if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); - } - } - } - ts.emitComments = emitComments; - function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { - var leadingComments; - var currentDetachedCommentInfo; - if (removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment = void 0; - for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { - var comment = leadingComments_1[_i]; - if (lastComment) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); - var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); - if (commentLine >= lastCommentLine + 2) { - break; - } - } - detachedComments.push(comment); - lastComment = comment; - } - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); - var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); - emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - } - } - } - return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; - } - } - ts.emitDetachedComments = emitDetachedComments; - function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42) { - var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); - var lineCount = lineMap.length; - var firstCommentLineIndent = void 0; - for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? text.length + 1 - : lineMap[currentLine + 1]; - if (pos !== commentPos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(text.substring(commentPos, commentEnd)); - } - } - ts.writeCommentRange = writeCommentRange; - function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { - var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== commentEnd) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(text, pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - function hasModifiers(node) { - return getModifierFlags(node) !== 0; - } - ts.hasModifiers = hasModifiers; - function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; - } - ts.hasModifier = hasModifier; - function getModifierFlags(node) { - if (node.modifierFlagsCache & 536870912) { - return node.modifierFlagsCache & ~536870912; - } - var flags = 0; - if (node.modifiers) { - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - flags |= modifierToFlag(modifier.kind); - } - } - if (node.flags & 4) { - flags |= 1; - } - node.modifierFlagsCache = flags | 536870912; - return flags; - } - ts.getModifierFlags = getModifierFlags; - function modifierToFlag(token) { - switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 129: return 64; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; - } - ts.isLogicalOperator = isLogicalOperator; - function isAssignmentOperator(token) { - return token >= 57 && token <= 69; - } - ts.isAssignmentOperator = isAssignmentOperator; - function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 && - node.parent.token === 84 && - isClassLike(node.parent.parent)) { - return node.parent.parent; - } - } - ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isDestructuringAssignment(node) { - if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 57) { - var kind = node.left.kind; - return kind === 172 - || kind === 171; - } - } - return false; - } - ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 173 && 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); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 172) { - return expression.properties.length === 0; - } - if (kind === 171) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function tryExtractTypeScriptExtension(fileName) { - return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - ts.stringify = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify - : stringifyFallback; - function stringifyFallback(value) { - return value === undefined ? undefined : stringifyValue(value); - } - function stringifyValue(value) { - return typeof value === "string" ? "\"" + escapeString(value) + "\"" - : typeof value === "number" ? isFinite(value) ? String(value) : "null" - : typeof value === "boolean" ? value ? "true" : "false" - : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) - : "null"; - } - function cycleCheck(cb, value) { - ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); - value.__cycle = true; - var result = cb(value); - delete value.__cycle; - return result; - } - function stringifyArray(value) { - return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; - } - function stringifyElement(memo, value) { - return (memo ? memo + "," : memo) + stringifyValue(value); - } - function stringifyObject(value) { - return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; - } - function stringifyProperty(memo, value, key) { - return value === undefined || typeof value === "function" || key === "__cycle" ? memo - : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 11 - || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { - return true; - } - else if (kind === 173) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 174) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 186 - || kind === 187) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 188) { - return node.operatorToken.kind !== 39 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 189) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 184 - || kind === 183 - || kind === 182) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 171) { - return node.elements.length === 0; - } - else if (kind === 172) { - return node.properties.length === 0; - } - else if (kind === 175) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } - var syntaxKindCache = ts.createMap(); - function formatSyntaxKind(kind) { - var syntaxKindEnum = ts.SyntaxKind; - if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; - } - for (var name_6 in syntaxKindEnum) { - if (syntaxKindEnum[name_6] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_6 + ")"; - } - } - } - else { - return kind.toString(); - } - } - ts.formatSyntaxKind = formatSyntaxKind; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; - function createRange(pos, end) { - return { pos: pos, end: end }; - } - ts.createRange = createRange; - function moveRangeEnd(range, end) { - return createRange(range.pos, end); - } - ts.moveRangeEnd = moveRangeEnd; - function moveRangePos(range, pos) { - return createRange(pos, range.end); - } - ts.moveRangePos = moveRangePos; - function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) - : node; - } - ts.moveRangePastDecorators = moveRangePastDecorators; - function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) - : moveRangePastDecorators(node); - } - ts.moveRangePastModifiers = moveRangePastModifiers; - function isCollapsedRange(range) { - return range.pos === range.end; - } - ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; - function createTokenRange(pos, token) { - return createRange(pos, pos + ts.tokenToString(token).length); - } - ts.createTokenRange = createTokenRange; - function rangeIsOnSingleLine(range, sourceFile) { - return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); - } - ts.rangeIsOnSingleLine = rangeIsOnSingleLine; - function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; - function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, range2.end, sourceFile); - } - ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; - function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); - } - ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; - function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; - function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); - } - ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); - } - ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { - var externalImports = []; - var exportSpecifiers = ts.createMap(); - 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: - externalImports.push(node); - break; - case 230: - if (node.moduleReference.kind === 241) { - externalImports.push(node); - } - break; - case 237: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } - else { - externalImports.push(node); - } - } - else { - for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { - var specifier = _c[_b]; - var name_7 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_7] || (exportSpecifiers[name_7] = [])).push(specifier); - } - } - break; - case 236: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; - } - ts.collectExternalModuleInfo = collectExternalModuleInfo; - function getInitializedVariables(node) { - return ts.filter(node.declarations, isInitializedVariable); - } - ts.getInitializedVariables = getInitializedVariables; - function isInitializedVariable(node) { - return node.initializer !== undefined; - } - function isMergedWithClass(node) { - 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) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; - function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - ts.isNodeArray = isNodeArray; - function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; - } - ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isLiteralExpression(node) { - return isLiteralKind(node.kind); - } - ts.isLiteralExpression = isLiteralExpression; - function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateHead(node) { - return node.kind === 13; - } - ts.isTemplateHead = isTemplateHead; - function isTemplateMiddleOrTemplateTail(node) { - var kind = node.kind; - return kind === 14 - || kind === 15; - } - ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; - function isIdentifier(node) { - return node.kind === 70; - } - ts.isIdentifier = isIdentifier; - function isGeneratedIdentifier(node) { - return isIdentifier(node) && node.autoGenerateKind > 0; - } - ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isModifier(node) { - return isModifierKind(node.kind); - } - ts.isModifier = isModifier; - function isQualifiedName(node) { - return node.kind === 140; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 141; - } - ts.isComputedPropertyName = isComputedPropertyName; - function isEntityName(node) { - var kind = node.kind; - return kind === 140 - || kind === 70; - } - ts.isEntityName = isEntityName; - function isPropertyName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9 - || kind === 8 - || kind === 141; - } - ts.isPropertyName = isPropertyName; - function isModuleName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9; - } - ts.isModuleName = isModuleName; - function isBindingName(node) { - var kind = node.kind; - return kind === 70 - || kind === 168 - || kind === 169; - } - ts.isBindingName = isBindingName; - function isTypeParameter(node) { - return node.kind === 142; - } - ts.isTypeParameter = isTypeParameter; - function isParameter(node) { - return node.kind === 143; - } - ts.isParameter = isParameter; - function isDecorator(node) { - return node.kind === 144; - } - ts.isDecorator = isDecorator; - function isMethodDeclaration(node) { - return node.kind === 148; - } - ts.isMethodDeclaration = isMethodDeclaration; - function isClassElement(node) { - var kind = node.kind; - return kind === 149 - || kind === 146 - || kind === 148 - || kind === 150 - || kind === 151 - || kind === 154 - || kind === 199; - } - ts.isClassElement = isClassElement; - function isObjectLiteralElementLike(node) { - var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 148 - || kind === 150 - || kind === 151 - || kind === 240; - } - ts.isObjectLiteralElementLike = isObjectLiteralElementLike; - function isTypeNodeKind(kind) { - return (kind >= 155 && kind <= 167) - || kind === 118 - || kind === 131 - || kind === 121 - || kind === 133 - || kind === 134 - || kind === 104 - || kind === 128 - || kind === 195; - } - function isTypeNode(node) { - return isTypeNodeKind(node.kind); - } - ts.isTypeNode = isTypeNode; - function isBindingPattern(node) { - if (node) { - var kind = node.kind; - return kind === 169 - || kind === 168; - } - return false; - } - ts.isBindingPattern = isBindingPattern; - function isBindingElement(node) { - return node.kind === 170; - } - ts.isBindingElement = isBindingElement; - function isArrayBindingElement(node) { - var kind = node.kind; - return kind === 170 - || kind === 194; - } - ts.isArrayBindingElement = isArrayBindingElement; - function isPropertyAccessExpression(node) { - return node.kind === 173; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 174; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isBinaryExpression(node) { - return node.kind === 188; - } - ts.isBinaryExpression = isBinaryExpression; - function isConditionalExpression(node) { - return node.kind === 189; - } - ts.isConditionalExpression = isConditionalExpression; - function isCallExpression(node) { - return node.kind === 175; - } - ts.isCallExpression = isCallExpression; - function isTemplateLiteral(node) { - var kind = node.kind; - return kind === 190 - || kind === 12; - } - ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192; - } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { - return node.kind === 195; - } - ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; - function isLeftHandSideExpressionKind(kind) { - return kind === 173 - || kind === 174 - || kind === 176 - || kind === 175 - || kind === 242 - || kind === 243 - || kind === 177 - || kind === 171 - || kind === 179 - || kind === 172 - || kind === 193 - || kind === 180 - || kind === 70 - || kind === 11 - || kind === 8 - || kind === 9 - || kind === 12 - || kind === 190 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 197; - } - 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 - || kind === 185 - || kind === 178 - || isLeftHandSideExpressionKind(kind); - } - function isUnaryExpression(node) { - return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isUnaryExpression = isUnaryExpression; - function isExpressionKind(kind) { - return kind === 189 - || kind === 191 - || kind === 181 - || kind === 188 - || kind === 192 - || kind === 196 - || kind === 194 - || isUnaryExpressionKind(kind); - } - function isExpression(node) { - return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isExpression = isExpression; - function isAssertionExpression(node) { - var kind = node.kind; - return kind === 178 - || kind === 196; - } - ts.isAssertionExpression = isAssertionExpression; - function isPartiallyEmittedExpression(node) { - return node.kind === 288; - } - ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; - function isNotEmittedStatement(node) { - return node.kind === 287; - } - ts.isNotEmittedStatement = isNotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node) { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; - function isOmittedExpression(node) { - return node.kind === 194; - } - ts.isOmittedExpression = isOmittedExpression; - function isTemplateSpan(node) { - return node.kind === 198; - } - ts.isTemplateSpan = isTemplateSpan; - function isBlock(node) { - return node.kind === 200; - } - ts.isBlock = isBlock; - function isConciseBody(node) { - return isBlock(node) - || isExpression(node); - } - ts.isConciseBody = isConciseBody; - function isFunctionBody(node) { - return isBlock(node); - } - ts.isFunctionBody = isFunctionBody; - function isForInitializer(node) { - return isVariableDeclarationList(node) - || isExpression(node); - } - ts.isForInitializer = isForInitializer; - function isVariableDeclaration(node) { - return node.kind === 219; - } - ts.isVariableDeclaration = isVariableDeclaration; - function isVariableDeclarationList(node) { - return node.kind === 220; - } - ts.isVariableDeclarationList = isVariableDeclarationList; - function isCaseBlock(node) { - return node.kind === 228; - } - ts.isCaseBlock = isCaseBlock; - function isModuleBody(node) { - var kind = node.kind; - return kind === 227 - || kind === 226; - } - ts.isModuleBody = isModuleBody; - function isImportEqualsDeclaration(node) { - return node.kind === 230; - } - ts.isImportEqualsDeclaration = isImportEqualsDeclaration; - function isImportClause(node) { - return node.kind === 232; - } - ts.isImportClause = isImportClause; - function isNamedImportBindings(node) { - var kind = node.kind; - return kind === 234 - || kind === 233; - } - ts.isNamedImportBindings = isNamedImportBindings; - function isImportSpecifier(node) { - return node.kind === 235; - } - ts.isImportSpecifier = isImportSpecifier; - function isNamedExports(node) { - return node.kind === 238; - } - ts.isNamedExports = isNamedExports; - function isExportSpecifier(node) { - return node.kind === 239; - } - ts.isExportSpecifier = isExportSpecifier; - function isModuleOrEnumDeclaration(node) { - return node.kind === 226 || node.kind === 225; - } - ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; - function isDeclarationKind(kind) { - return kind === 181 - || kind === 170 - || kind === 222 - || kind === 193 - || kind === 149 - || kind === 225 - || kind === 255 - || kind === 239 - || kind === 221 - || kind === 180 - || 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 === 224 - || kind === 142 - || kind === 219 - || kind === 279; - } - function isDeclarationStatementKind(kind) { - return kind === 221 - || kind === 240 - || kind === 222 - || kind === 223 - || kind === 224 - || kind === 225 - || kind === 226 - || kind === 231 - || kind === 230 - || kind === 237 - || kind === 236 - || kind === 229; - } - 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 - || kind === 213 - || kind === 287; - } - function isDeclaration(node) { - return isDeclarationKind(node.kind); - } - ts.isDeclaration = isDeclaration; - function isDeclarationStatement(node) { - return isDeclarationStatementKind(node.kind); - } - ts.isDeclarationStatement = isDeclarationStatement; - function isStatementButNotDeclaration(node) { - return isStatementKindButNotDeclarationKind(node.kind); - } - ts.isStatementButNotDeclaration = isStatementButNotDeclaration; - function isStatement(node) { - var kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === 200; - } - ts.isStatement = isStatement; - function isModuleReference(node) { - var kind = node.kind; - return kind === 241 - || kind === 140 - || kind === 70; - } - ts.isModuleReference = isModuleReference; - function isJsxOpeningElement(node) { - return node.kind === 244; - } - ts.isJsxOpeningElement = isJsxOpeningElement; - function isJsxClosingElement(node) { - return node.kind === 245; - } - ts.isJsxClosingElement = isJsxClosingElement; - function isJsxTagNameExpression(node) { - var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 173; - } - ts.isJsxTagNameExpression = isJsxTagNameExpression; - function isJsxChild(node) { - var kind = node.kind; - return kind === 242 - || kind === 248 - || kind === 243 - || kind === 10; - } - ts.isJsxChild = isJsxChild; - function isJsxAttributeLike(node) { - var kind = node.kind; - return kind === 246 - || kind === 247; - } - ts.isJsxAttributeLike = isJsxAttributeLike; - function isJsxSpreadAttribute(node) { - return node.kind === 247; - } - ts.isJsxSpreadAttribute = isJsxSpreadAttribute; - function isJsxAttribute(node) { - return node.kind === 246; - } - ts.isJsxAttribute = isJsxAttribute; - function isStringLiteralOrJsxExpression(node) { - var kind = node.kind; - return kind === 9 - || kind === 248; - } - ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; - function isCaseOrDefaultClause(node) { - var kind = node.kind; - return kind === 249 - || kind === 250; - } - ts.isCaseOrDefaultClause = isCaseOrDefaultClause; - function isHeritageClause(node) { - return node.kind === 251; - } - ts.isHeritageClause = isHeritageClause; - function isCatchClause(node) { - return node.kind === 252; - } - ts.isCatchClause = isCatchClause; - function isPropertyAssignment(node) { - return node.kind === 253; - } - ts.isPropertyAssignment = isPropertyAssignment; - function isShorthandPropertyAssignment(node) { - return node.kind === 254; - } - ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; - function isEnumMember(node) { - return node.kind === 255; - } - ts.isEnumMember = isEnumMember; - function isSourceFile(node) { - return node.kind === 256; - } - ts.isSourceFile = isSourceFile; - function isWatchSet(options) { - return options.watch && options.hasOwnProperty("watch"); - } - ts.isWatchSet = isWatchSet; -})(ts || (ts = {})); -(function (ts) { - function getDefaultLibFileName(options) { - switch (options.target) { - case 4: - return "lib.es2017.d.ts"; - case 3: - return "lib.es2016.d.ts"; - case 2: - return "lib.es6.d.ts"; - default: - return "lib.d.ts"; - } - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 142) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); - } - ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 || ts.isBindingPattern(node))) { - node = node.parent; - } - return node; - } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 219) { - node = node.parent; - } - if (node && node.kind === 220) { - flags |= ts.getModifierFlags(node); - node = node.parent; - } - if (node && node.kind === 201) { - flags |= ts.getModifierFlags(node); - } - return flags; - } - ts.getCombinedModifierFlags = getCombinedModifierFlags; - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 219) { - node = node.parent; - } - if (node && node.kind === 220) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 201) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; -})(ts || (ts = {})); -var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { return token >= 70; @@ -8088,7 +3206,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -8098,34 +3216,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, @@ -8133,7 +3252,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -8228,8 +3347,8 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_8 in source) { - result[source[name_8]] = name_8; + for (var name_4 in source) { + result[source[name_4]] = name_4; } return result; } @@ -9516,10 +4635,13 @@ var ts; case 44: pos++; return token = 25; + case 46: + 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; @@ -9607,11 +4729,5885 @@ var ts; ts.createScanner = createScanner; })(ts || (ts = {})); var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMap({ + "preserve": 1, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + }, + { + name: "reactNamespace", + 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", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMap({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMap({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_in_the_given_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMap({ + "es3": 0, + "es5": 1, + "es6": 2, + "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, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMap({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMap({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.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.string": "lib.es2017.string.d.ts", + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + } + ]; + ts.typingOptionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } + } + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + var key = trimString((value || "")).toLowerCase(); + var map = opt.type; + if (key in map) { + return map[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + if (s in shortOptionNames) { + s = shortOptionNames[s]; + } + if (s in optionNameMap) { + var opt = optionNameMap[s]; + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } + } + } + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + for (var key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; + } + } + return undefined; + } + function serializeCompilerOptions(options) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name_5 in options) { + if (ts.hasProperty(options, name_5)) { + switch (name_5) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name_5]; + var optionDefinition = optionsNameMap[name_5.toLowerCase()]; + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name_5] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name_5] = convertedValue; + } + else { + result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + var errors = []; + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typingOptions: typingOptions, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); + } + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); + } + } + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + 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; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (id in optionNameMap) { + var opt = optionNameMap[id]; + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + } + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + if (key in opt.type) { + return opt.type[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap[keyMapper(file)] = file; + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { + wildcardFileMap[key] = file; + } + } + } + var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); + var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); + wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { + var spec = specs_2[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = ts.createMap(); + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { + continue; + } + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); + if (match) { + var key = match.key, flags = match.flags; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } + } + } + for (var key in wildcardDirectories) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } + } + } + } + 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); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + return true; + } + } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + delete wildcardFiles[lowerPriorityPath]; + } + } + function addFileToOutput(output, file) { + output.push(file); + return output; + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); + } +})(ts || (ts = {})); +var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } + } + } + 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++) { + var excludeTypingName = exclude_1[_b]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventInstall = "event::install"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +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"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typingOptions, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; }, + startRecordingFilesWithChangedResolutions: function () { return undefined; }, + finishRecordingFilesWithChangedResolutions: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function trace(host) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + 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 }; + } + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + 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 = 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); + } + return typesFilePath; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + }); + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + } + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + } + function secondaryLookup() { + var resolvedFile; + 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 = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + if (!resolvedFile && traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + } + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + 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]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); + } + else { + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); + } + } + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + 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(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, false, state); + return path_1 && { path: path_1, extension: tsExtension }; + } + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + 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(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + 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, 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); + } + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + } + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + 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 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(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + 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, failedLookupLocations, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + 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, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocations.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); + if (x) { + return x; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); + } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + 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)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + } + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + } + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + } + }); + } + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== 1) { + return loadModuleFromNodeModulesFolder(2, 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 }; + var failedLookupLocations = []; + var containingDirectory = ts.getDirectoryPath(containingFile); + 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 = forEachAncestorDirectory(containingDirectory, function (directory) { + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, 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); + } + } + } + ts.classicNameResolver = classicNameResolver; + 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 = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.externalHelpersModuleNameText = "tslib"; + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; + return { + string: function () { return str_1; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str_1 += " "; }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, + clear: function () { return str_1 = ""; }, + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasResolvedModule(sourceFile, moduleNameText) { + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = ts.createMap(); + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { + if (!sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + } + sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + } + ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; + function moduleResolutionIsEqualTo(oldResolution, newResolution) { + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; + } + ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function typeDirectiveIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + } + ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; + function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + if (names.length !== newResolutions.length) { + return false; + } + for (var i = 0; i < names.length; i++) { + var newResolution = newResolutions[i]; + var oldResolution = oldResolutions && oldResolutions[names[i]]; + var changed = oldResolution + ? !newResolution || !comparer(oldResolution, newResolution) + : newResolution; + if (changed) { + return true; + } + } + return false; + } + ts.hasChangesInResolutions = hasChangesInResolutions; + function containsParseError(node) { + aggregateChildData(node); + return (node.flags & 4194304) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.flags & 8388608)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.flags |= 4194304; + } + node.flags |= 8388608; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 261) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 204: + case 232: + case 211: + case 212: + case 213: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function isDefined(value) { + return value !== undefined; + } + ts.isDefined = isDefined; + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = ts.getLineStarts(sourceFile); + var lineIndex = line; + var sourceText = sourceFile.text; + if (lineIndex + 1 === lineStarts.length) { + return sourceText.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function nodeIsMissing(node) { + if (node === undefined) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { + if (nodeIsMissing(node)) { + return node.pos; + } + if (isJSDocNode(node)) { + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); + } + if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { + return getTokenPosOfNode(node.jsDocComments[0]); + } + if (node.kind === 291 && 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 >= 262 && node.kind <= 287; + } + ts.isJSDocNode = isJSDocNode; + function isJSDocTag(node) { + return node.kind >= 278 && node.kind <= 290; + } + ts.isJSDocTag = isJSDocTag; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function getLiteralText(node, sourceFile, languageVersion) { + if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + if (!nodeIsSynthesized(node) && node.parent) { + var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); + if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; + } + return text; + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 13: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + ts.getLiteralText = getLiteralText; + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + } + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || + isCatchClauseVariableDeclarationOrBindingElement(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 223 && node.parent.kind === 256; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; + function isAmbientModule(node) { + return node && node.kind === 230 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isShorthandAmbientModuleSymbol(moduleSymbol) { + return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + } + ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; + function isShorthandAmbientModule(node) { + return node.kind === 230 && (!node.body); + } + function isBlockScopedContainerTopLevel(node) { + return node.kind === 261 || + node.kind === 230 || + isFunctionLike(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 512); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 261: + return ts.isExternalModule(node.parent); + case 231: + return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isBlockScope(node, parentNode) { + switch (node.kind) { + case 261: + case 232: + case 256: + case 230: + case 211: + case 212: + case 213: + case 150: + case 149: + case 151: + case 152: + case 225: + case 184: + case 185: + return true; + case 204: + return parentNode && !isFunctionLike(parentNode); + } + return false; + } + ts.isBlockScope = isBlockScope; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isBlockScope(current, current.parent)) { + return current; + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function declarationNameToString(name) { + 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 177: + 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.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForArrowFunction(sourceFile, node) { + var pos = ts.skipTrivia(sourceFile.text, node.pos); + if (node.body && node.body.kind === 204) { + var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; + if (startLine < endLine) { + return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); + } + } + return ts.createTextSpanFromBounds(pos, node.end); + } + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 261: + 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 223: + case 174: + case 226: + case 197: + case 227: + case 230: + case 229: + case 260: + case 225: + case 184: + case 149: + case 151: + case 152: + case 228: + errorNode = node.name; + break; + case 185: + return getErrorSpanForArrowFunction(sourceFile, node); + } + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; + function isDeclarationFile(file) { + return file.isDeclarationFile; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 229 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function isConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2) + || !!(ts.getCombinedModifierFlags(node) & 2048); + } + ts.isConst = isConst; + function isLet(node) { + return !!(ts.getCombinedNodeFlags(node) & 1); + } + ts.isLet = isLet; + function isSuperCall(n) { + return n.kind === 179 && n.expression.kind === 96; + } + ts.isSuperCall = isSuperCall; + function isPrologueDirective(node) { + return node.kind === 207 && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getLeadingCommentRangesOfNodeFromText(node, text) { + return ts.getLeadingCommentRanges(text, node.pos); + } + ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; + function getJsDocComments(node, sourceFileOfNode) { + return getJsDocCommentsFromText(node, sourceFileOfNode.text); + } + ts.getJsDocComments = getJsDocComments; + function getJsDocCommentsFromText(node, text) { + var commentRanges = (node.kind === 144 || + node.kind === 143 || + node.kind === 184 || + node.kind === 185) ? + ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : + getLeadingCommentRangesOfNodeFromText(node, text); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 42 && + text.charCodeAt(comment.pos + 3) !== 47; + } + } + ts.getJsDocCommentsFromText = getJsDocCommentsFromText; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isPartOfTypeNode(node) { + if (156 <= node.kind && node.kind <= 171) { + return true; + } + switch (node.kind) { + case 118: + case 132: + case 134: + case 121: + case 135: + case 137: + case 129: + return true; + case 104: + return node.parent.kind !== 188; + case 199: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 70: + if (node.parent.kind === 141 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 177 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141: + case 177: + case 98: + var parent_1 = node.parent; + if (parent_1.kind === 160) { + return false; + } + if (156 <= parent_1.kind && parent_1.kind <= 171) { + return true; + } + switch (parent_1.kind) { + case 199: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 143: + return node === parent_1.constraint; + case 147: + case 146: + case 144: + case 223: + return node === parent_1.type; + case 225: + case 184: + case 185: + case 150: + case 149: + case 148: + case 151: + case 152: + return node === parent_1.type; + case 153: + case 154: + case 155: + return node === parent_1.type; + case 182: + return node === parent_1.type; + case 179: + case 180: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 181: + return false; + } + } + return false; + } + ts.isPartOfTypeNode = isPartOfTypeNode; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 216: + return visitor(node); + case 232: + case 204: + case 208: + case 209: + case 210: + case 211: + case 212: + case 213: + case 217: + case 218: + case 253: + case 254: + case 219: + case 221: + case 256: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 195: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 229: + case 227: + case 230: + case 228: + case 226: + case 197: + return; + default: + if (isFunctionLike(node)) { + var name_7 = node.name; + if (name_7 && name_7.kind === 142) { + traverse(name_7.expression); + return; + } + } + else if (!isPartOfTypeNode(node)) { + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 174: + case 260: + case 144: + case 257: + case 147: + case 146: + case 258: + case 223: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 151 || node.kind === 152); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 226 || node.kind === 197); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + return node && isFunctionLikeKind(node.kind); + } + ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 150: + case 184: + case 225: + case 185: + case 149: + case 148: + case 151: + case 152: + case 153: + case 154: + case 155: + case 158: + case 159: + return true; + } + return false; + } + ts.isFunctionLikeKind = isFunctionLikeKind; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 149: + case 148: + case 150: + case 151: + case 152: + case 225: + case 184: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 211: + case 212: + case 213: + case 209: + case 210: + return true; + case 219: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 204 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 149 && node.parent.kind === 176; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 149 && + (node.parent.kind === 176 || + node.parent.kind === 197); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + function isIdentifierTypePredicate(predicate) { + return predicate && predicate.kind === 1; + } + ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 142: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + 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 185: + if (!includeArrowFunctions) { + continue; + } + case 225: + case 184: + case 230: + case 147: + case 146: + case 149: + case 148: + case 150: + case 151: + case 152: + case 153: + case 154: + case 155: + case 229: + case 261: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, stopOnFunctions) { + while (true) { + node = node.parent; + if (!node) { + return node; + } + switch (node.kind) { + case 142: + node = node.parent; + break; + case 225: + case 184: + case 185: + if (!stopOnFunctions) { + continue; + } + case 147: + case 146: + case 149: + case 148: + case 150: + case 151: + case 152: + return node; + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getImmediatelyInvokedFunctionExpression(func) { + if (func.kind === 184 || func.kind === 185) { + var prev = func; + var parent_2 = func.parent; + while (parent_2.kind === 183) { + prev = parent_2; + parent_2 = parent_2.parent; + } + if (parent_2.kind === 179 && parent_2.expression === prev) { + return parent_2; + } + } + } + ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; + function isSuperProperty(node) { + var kind = node.kind; + return (kind === 177 || kind === 178) + && node.expression.kind === 96; + } + ts.isSuperProperty = isSuperProperty; + function getEntityNameFromTypeNode(node) { + switch (node.kind) { + case 157: + case 272: + return node.typeName; + case 199: + 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 179: + case 180: + case 181: + case 145: + return true; + default: + return false; + } + } + ts.isCallLikeExpression = isCallLikeExpression; + function getInvokedExpression(node) { + if (node.kind === 181) { + return node.tag; + } + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 226: + return true; + case 147: + return node.parent.kind === 226; + case 151: + case 152: + case 149: + return node.body !== undefined + && node.parent.kind === 226; + case 144: + return node.parent.body !== undefined + && (node.parent.kind === 150 + || node.parent.kind === 149 + || node.parent.kind === 152) + && node.parent.parent.kind === 226; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + return node.decorators !== undefined + && nodeCanBeDecorated(node); + } + ts.nodeIsDecorated = nodeIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 226: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 149: + case 152: + return ts.forEach(node.parameters, nodeIsDecorated); + } + } + ts.childIsDecorated = childIsDecorated; + function isJSXTagName(node) { + var parent = node.parent; + if (parent.kind === 248 || + parent.kind === 247 || + parent.kind === 249) { + return parent.tagName === node; + } + return false; + } + ts.isJSXTagName = isJSXTagName; + function isPartOfExpression(node) { + switch (node.kind) { + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: + case 175: + case 176: + case 177: + case 178: + case 179: + case 180: + case 181: + case 200: + case 182: + case 201: + case 183: + case 184: + case 197: + case 185: + case 188: + case 186: + case 187: + case 190: + case 191: + case 192: + case 193: + case 196: + case 194: + case 12: + case 198: + case 246: + case 247: + case 195: + case 189: + return true; + case 141: + while (node.parent.kind === 141) { + node = node.parent; + } + return node.parent.kind === 160 || isJSXTagName(node); + case 70: + if (node.parent.kind === 160 || isJSXTagName(node)) { + return true; + } + case 8: + case 9: + case 98: + var parent_3 = node.parent; + switch (parent_3.kind) { + case 223: + case 144: + case 147: + case 146: + case 260: + case 257: + case 174: + return parent_3.initializer === node; + case 207: + case 208: + case 209: + case 210: + case 216: + case 217: + case 218: + case 253: + case 220: + case 218: + return parent_3.expression === node; + case 211: + var forStatement = parent_3; + return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + forStatement.condition === node || + forStatement.incrementor === node; + case 212: + case 213: + var forInStatement = parent_3; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + forInStatement.expression === node; + case 182: + case 200: + return node === parent_3.expression; + case 202: + return node === parent_3.expression; + case 142: + return node === parent_3.expression; + case 145: + case 252: + case 251: + return true; + case 199: + return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + default: + if (isPartOfExpression(parent_3)) { + return true; + } + } + } + return false; + } + ts.isPartOfExpression = isPartOfExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 234 && node.moduleReference.kind === 245; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 234 && node.moduleReference.kind !== 245; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.flags & 2097152); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 179 && + expression.expression.kind === 70 && + expression.expression.text === "require" && + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + } + ts.isRequireCall = isRequireCall; + function isSingleOrDoubleQuote(charCode) { + return charCode === 39 || charCode === 34; + } + ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; + function isDeclarationOfFunctionExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + var declaration = s.valueDeclaration; + return declaration.initializer && declaration.initializer.kind === 184; + } + return false; + } + ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + function getSpecialPropertyAssignmentKind(expression) { + if (!isInJavaScriptFile(expression)) { + return 0; + } + if (expression.kind !== 192) { + return 0; + } + var expr = expression; + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { + return 0; + } + var lhs = expr.left; + if (lhs.expression.kind === 70) { + var lhsId = lhs.expression; + if (lhsId.text === "exports") { + return 1; + } + else if (lhsId.text === "module" && lhs.name.text === "exports") { + return 2; + } + } + else if (lhs.expression.kind === 98) { + return 4; + } + else if (lhs.expression.kind === 177) { + var innerPropertyAccess = lhs.expression; + if (innerPropertyAccess.expression.kind === 70) { + var innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return 1; + } + if (innerPropertyAccess.name.text === "prototype") { + return 3; + } + } + } + return 0; + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getExternalModuleName(node) { + if (node.kind === 235) { + return node.moduleSpecifier; + } + if (node.kind === 234) { + var reference = node.moduleReference; + if (reference.kind === 245) { + return reference.expression; + } + } + if (node.kind === 241) { + return node.moduleSpecifier; + } + if (node.kind === 230 && node.name.kind === 9) { + return node.name; + } + } + ts.getExternalModuleName = getExternalModuleName; + function getNamespaceDeclarationNode(node) { + if (node.kind === 234) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + return importClause.namedBindings; + } + } + ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; + function isDefaultImport(node) { + return node.kind === 235 + && node.importClause + && !!node.importClause.name; + } + ts.isDefaultImport = isDefaultImport; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 144: + case 149: + case 148: + case 258: + case 257: + case 147: + case 146: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 274 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 276; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; + } + var jsDocTags = getJSDocTags(node, checkParentVariableStatement); + if (!jsDocTags) { + return undefined; + } + for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { + var tag = jsDocTags_1[_i]; + if (tag.kind === kind) { + return tag; + } + } + } + function append(previous, additional) { + if (additional) { + if (!previous) { + previous = []; + } + for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { + var x = additional_1[_i]; + previous.push(x); + } + } + return previous; + } + function getJSDocComments(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); + } + ts.getJSDocComments = getJSDocComments; + function getJSDocTags(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { + var result = []; + for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { + var doc = docs_1[_i]; + if (doc.tags) { + result.push.apply(result, doc.tags); + } + } + return result; + }, function (tags) { return tags; }); + } + function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { + var result = undefined; + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && + (node.parent).initializer === node && + node.parent.parent.parent.kind === 205; + var isVariableOfVariableDeclarationStatement = isVariableLike(node) && + node.parent.parent.kind === 205; + 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 === 230 && + node.parent && node.parent.kind === 230) { + result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); + } + var parent_4 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && + parent_4.kind === 192 && + parent_4.operatorToken.kind === 57 && + parent_4.parent.kind === 207; + if (isSourceOfAssignmentExpressionStatement) { + result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); + } + var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 257; + if (isPropertyAssignmentExpression) { + result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === 144) { + var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); + if (paramTags) { + result = append(result, getTags(paramTags)); + } + } + } + if (isVariableLike(node) && node.initializer) { + result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); + } + if (node.jsDocComments) { + if (result) { + result = append(result, getDocs(node.jsDocComments)); + } + else { + return getDocs(node.jsDocComments); + } + } + return result; + } + function getJSDocParameterTag(param, checkParentVariableStatement) { + var func = param.parent; + var tags = getJSDocTags(func, checkParentVariableStatement); + if (!param.name) { + var i = func.parameters.indexOf(param); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 280; }); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; + } + } + else if (param.name.kind === 70) { + var name_8 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 280 && tag.parameterName.text === name_8; }); + if (paramTags) { + return paramTags; + } + } + else { + return undefined; + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 282, false); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 281, true); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 283, false); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 70) { + var parameterName = parameter.name.text; + var jsDocTags = getJSDocTags(parameter.parent, true); + if (!jsDocTags) { + return undefined; + } + for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { + var tag = jsDocTags_2[_i]; + if (tag.kind === 280) { + var parameterTag = tag; + if (parameterTag.parameterName.text === parameterName) { + return parameterTag; + } + } + } + } + return undefined; + } + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function hasDeclaredRestParameter(s) { + return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); + } + ts.hasDeclaredRestParameter = hasDeclaredRestParameter; + function isRestParameter(node) { + if (node && (node.flags & 2097152)) { + if (node.type && node.type.kind === 275) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 275; + } + } + return isDeclaredRestParam(node); + } + ts.isRestParameter = isRestParameter; + function isDeclaredRestParam(node) { + return node && node.dotDotDotToken !== undefined; + } + ts.isDeclaredRestParam = isDeclaredRestParam; + function getAssignmentTargetKind(node) { + var parent = node.parent; + while (true) { + switch (parent.kind) { + case 192: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 190: + case 191: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 212: + case 213: + return parent.initializer === node ? 1 : 0; + case 183: + case 175: + case 196: + node = parent; + break; + case 258: + if (parent.name !== node) { + return 0; + } + case 257: + node = parent.parent; + break; + default: + return 0; + } + parent = node.parent; + } + } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } + ts.isAssignmentTarget = isAssignmentTarget; + function isNodeDescendantOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendantOf = isNodeDescendantOf; + function isInAmbientContext(node) { + while (node) { + if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclarationName(name) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 239 || parent.kind === 243) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + function isLiteralComputedPropertyDeclarationName(node) { + return (node.kind === 9 || node.kind === 8) && + node.parent.kind === 142 && + isDeclaration(node.parent.parent); + } + ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 147: + case 146: + case 149: + case 148: + case 151: + case 152: + case 260: + case 257: + case 177: + return parent.name === node; + case 141: + if (parent.right === node) { + while (parent.kind === 141) { + parent = parent.parent; + } + return parent.kind === 160; + } + return false; + case 174: + case 239: + return parent.propertyName === node; + case 243: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 234 || + node.kind === 233 || + node.kind === 236 && !!node.name || + node.kind === 237 || + node.kind === 239 || + node.kind === 243 || + node.kind === 240 && exportAssignmentIsAlias(node); + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function exportAssignmentIsAlias(node) { + return isEntityNameExpression(node.expression); + } + ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 107); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.test(comment)) { + if (isNoDefaultLibRegEx.test(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + if (refMatchResult || refLibResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: (refMatchResult || refLibResult)[3] + }, + isNoDefaultLib: false, + isTypeReferenceDirective: !!refLibResult + }; + } + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 71 <= token && token <= 140; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function isStringOrNumericLiteral(kind) { + return kind === 9 || kind === 8; + } + ts.isStringOrNumericLiteral = isStringOrNumericLiteral; + function hasDynamicName(declaration) { + return declaration.name && isDynamicName(declaration.name); + } + ts.hasDynamicName = hasDynamicName; + function isDynamicName(name) { + return name.kind === 142 && + !isStringOrNumericLiteral(name.expression.kind) && + !isWellKnownSymbolSyntactically(name.expression); + } + ts.isDynamicName = isDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { + return name.text; + } + if (name.kind === 142) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + else if (nameExpression.kind === 9 || nameExpression.kind === 8) { + return nameExpression.text; + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 70 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; + function isModifierKind(token) { + switch (token) { + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: + case 113: + case 111: + case 112: + case 130: + case 114: + return true; + } + return false; + } + ts.isModifierKind = isModifierKind; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 144; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 174) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(node) { + var kind = node.kind; + return kind === 150 + || kind === 184 + || kind === 225 + || kind === 185 + || kind === 149 + || kind === 151 + || kind === 152 + || kind === 230 + || kind === 261; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function nodeIsSynthesized(node) { + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function getOriginalSourceFiles(sourceFiles) { + var originalSourceFiles = []; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); + if (originalSourceFile) { + originalSourceFiles.push(originalSourceFile); + } + } + return originalSourceFiles; + } + ts.getOriginalSourceFiles = getOriginalSourceFiles; + function getOriginalNodeId(node) { + node = getOriginalNode(node); + return node ? ts.getNodeId(node) : 0; + } + ts.getOriginalNodeId = getOriginalNodeId; + function getExpressionAssociativity(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + return getOperatorAssociativity(expression.kind, operator, hasArguments); + } + ts.getExpressionAssociativity = getExpressionAssociativity; + function getOperatorAssociativity(kind, operator, hasArguments) { + switch (kind) { + case 180: + return hasArguments ? 0 : 1; + case 190: + case 187: + case 188: + case 186: + case 189: + case 193: + case 195: + return 1; + case 192: + switch (operator) { + case 39: + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 1; + } + } + return 0; + } + ts.getOperatorAssociativity = getOperatorAssociativity; + function getExpressionPrecedence(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + return getOperatorPrecedence(expression.kind, operator, hasArguments); + } + ts.getExpressionPrecedence = getExpressionPrecedence; + function getOperator(expression) { + if (expression.kind === 192) { + return expression.operatorToken.kind; + } + else if (expression.kind === 190 || expression.kind === 191) { + return expression.operator; + } + else { + return expression.kind; + } + } + ts.getOperator = getOperator; + function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { + switch (nodeKind) { + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: + case 8: + case 9: + case 175: + case 176: + case 184: + case 185: + case 197: + case 246: + case 247: + case 11: + case 12: + case 194: + case 183: + case 198: + return 19; + case 181: + case 177: + case 178: + return 18; + case 180: + return hasArguments ? 18 : 17; + case 179: + return 17; + case 191: + return 16; + case 190: + case 187: + case 188: + case 186: + case 189: + return 15; + case 192: + switch (operatorKind) { + case 50: + case 51: + return 15; + case 39: + case 38: + case 40: + case 41: + return 14; + case 36: + case 37: + return 13; + case 44: + case 45: + case 46: + return 12; + case 26: + case 29: + case 28: + case 30: + case 91: + case 92: + return 11; + case 31: + case 33: + case 32: + case 34: + return 10; + case 47: + return 9; + case 49: + return 8; + case 48: + return 7; + case 52: + return 6; + case 53: + return 5; + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 3; + case 25: + return 0; + default: + return -1; + } + case 193: + return 4; + case 195: + return 2; + case 196: + return 1; + default: + return -1; + } + } + ts.getOperatorPrecedence = getOperatorPrecedence; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = ts.createMap(); + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); + } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + } + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = ts.createMap({ + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }); + function escapeString(s) { + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + } + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output; + var indent; + var lineStart; + var lineCount; + var linePos; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function reset() { + output = ""; + indent = 0; + lineStart = true; + lineCount = 0; + linePos = 0; + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(text, node) { + write(getTextOfNodeFromSourceText(text, node)); + } + reset(); + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + isAtStartOfLine: function () { return lineStart; }, + reset: reset + }; + } + ts.createTextWriter = createTextWriter; + function getResolvedExternalModuleName(host, file) { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getExternalModuleNameFromDeclaration(host, resolver, declaration) { + var file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; + } + return getResolvedExternalModuleName(host, file); + } + ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; + function getExternalModuleNameFromPath(host, fileName) { + var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; + var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); + return ts.removeFileExtension(relativePath); + } + ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getDeclarationEmitOutputFilePath(sourceFile, host) { + var options = host.getCompilerOptions(); + var outputDir = options.declarationDir || options.outDir; + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; + } + ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; + function getSourceFilesToEmit(host, targetSourceFile) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + var moduleKind = ts.getEmitModuleKind(options); + var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + var sourceFiles = getAllEmittableSourceFiles(); + return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + } + else { + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; + return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); + } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } + } + ts.getSourceFilesToEmit = getSourceFilesToEmit; + function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { + return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + } + ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; + function isNonDeclarationFile(sourceFile) { + return !isDeclarationFile(sourceFile); + } + function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { + return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } + function isBundleEmitNonExternalModule(sourceFile) { + return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + } + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(sourceFiles); + } + else { + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + onSingleFileEmit(host, sourceFile); + } + } + } + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); + } + function onBundledEmit(sourceFiles) { + if (sourceFiles.length) { + var jsFilePath = options.outFile || options.out; + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + } + } + } + ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + function getSourceMapFilePath(jsFilePath, options) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(host); + } + else { + 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 (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { + onSingleFileEmit(host, sourceFile); + } + } + } + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: declarationFilePath + }; + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); + } + function onBundledEmit(host) { + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && + !host.isSourceFileFromExternalLibrary(sourceFile) && + (!ts.isExternalModule(sourceFile) || + !!ts.getEmitModuleKind(options)); }); + if (bundledSources.length) { + var jsFilePath = options.outFile || options.out; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined + }; + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + } + } + } + ts.forEachExpectedEmitFile = forEachExpectedEmitFile; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + var commonSourceDirectory = host.getCommonSourceDirectory(); + var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }, sourceFiles); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getLineOfLocalPositionFromLineMap(lineMap, pos) { + return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + } + ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 150 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + if (accessor && accessor.parameters.length > 0) { + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0].type; + } + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 70 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 98; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 151) { + getAccessor = accessor; + } + else if (accessor.kind === 152) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 151 || member.kind === 152) + && hasModifier(member, 32) === hasModifier(accessor, 32)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 151 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 152 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { + emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { + if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { + if (pos !== commentPos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; + function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { + if (comments && comments.length > 0) { + if (leadingSeparator) { + writer.write(" "); + } + var emitInterveningSeparator = false; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + if (emitInterveningSeparator) { + writer.write(" "); + emitInterveningSeparator = false; + } + writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else { + emitInterveningSeparator = true; + } + } + if (emitInterveningSeparator && trailingSeparator) { + writer.write(" "); + } + } + } + ts.emitComments = emitComments; + function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment = void 0; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); + var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); + emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; + function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (text.charCodeAt(commentPos + 1) === 42) { + var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); + var lineCount = lineMap.length; + var firstCommentLineIndent = void 0; + for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? text.length + 1 + : lineMap[currentLine + 1]; + if (pos !== commentPos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(text.substring(commentPos, commentEnd)); + } + } + ts.writeCommentRange = writeCommentRange; + function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { + var end = Math.min(commentEnd, nextLineStart - 1); + var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== commentEnd) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(text, pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { + if (text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + function hasModifiers(node) { + return getModifierFlags(node) !== 0; + } + ts.hasModifiers = hasModifiers; + function hasModifier(node, flags) { + return (getModifierFlags(node) & flags) !== 0; + } + ts.hasModifier = hasModifier; + function getModifierFlags(node) { + if (node.modifierFlagsCache & 536870912) { + return node.modifierFlagsCache & ~536870912; + } + var flags = 0; + if (node.modifiers) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + flags |= modifierToFlag(modifier.kind); + } + } + if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + flags |= 1; + } + node.modifierFlagsCache = flags | 536870912; + return flags; + } + ts.getModifierFlags = getModifierFlags; + function modifierToFlag(token) { + switch (token) { + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 130: return 64; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLogicalOperator(token) { + return token === 53 + || token === 52 + || token === 50; + } + ts.isLogicalOperator = isLogicalOperator; + function isAssignmentOperator(token) { + return token >= 57 && token <= 69; + } + ts.isAssignmentOperator = isAssignmentOperator; + function tryGetClassExtendingExpressionWithTypeArguments(node) { + if (node.kind === 199 && + 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 === 176 + || kind === 175; + } + } + return false; + } + ts.isDestructuringAssignment = isDestructuringAssignment; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 70) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isEntityNameExpression(node) { + return node.kind === 70 || + node.kind === 177 && isEntityNameExpression(node.expression); + } + ts.isEntityNameExpression = isEntityNameExpression; + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 141 && node.parent.right === node) || + (node.parent.kind === 177 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 176) { + return expression.properties.length === 0; + } + if (kind === 175) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function tryExtractTypeScriptExtension(fileName) { + return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + } + ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + ts.stringify = typeof JSON !== "undefined" && JSON.stringify + ? JSON.stringify + : stringifyFallback; + function stringifyFallback(value) { + return value === undefined ? undefined : stringifyValue(value); + } + function stringifyValue(value) { + return typeof value === "string" ? "\"" + escapeString(value) + "\"" + : typeof value === "number" ? isFinite(value) ? String(value) : "null" + : typeof value === "boolean" ? value ? "true" : "false" + : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) + : "null"; + } + function cycleCheck(cb, value) { + ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); + value.__cycle = true; + var result = cb(value); + delete value.__cycle; + return result; + } + function stringifyArray(value) { + return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; + } + function stringifyElement(memo, value) { + return (memo ? memo + "," : memo) + stringifyValue(value); + } + function stringifyObject(value) { + return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; + } + function stringifyProperty(memo, value, key) { + return value === undefined || typeof value === "function" || key === "__cycle" ? memo + : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; + function isSimpleExpression(node) { + return isSimpleExpressionWorker(node, 0); + } + ts.isSimpleExpression = isSimpleExpression; + function isSimpleExpressionWorker(node, depth) { + if (depth <= 5) { + var kind = node.kind; + if (kind === 9 + || kind === 8 + || kind === 11 + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { + return true; + } + else if (kind === 177) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 178) { + return isSimpleExpressionWorker(node.expression, depth + 1) + && isSimpleExpressionWorker(node.argumentExpression, depth + 1); + } + else if (kind === 190 + || kind === 191) { + return isSimpleExpressionWorker(node.operand, depth + 1); + } + else if (kind === 192) { + return node.operatorToken.kind !== 39 + && isSimpleExpressionWorker(node.left, depth + 1) + && isSimpleExpressionWorker(node.right, depth + 1); + } + else if (kind === 193) { + return isSimpleExpressionWorker(node.condition, depth + 1) + && isSimpleExpressionWorker(node.whenTrue, depth + 1) + && isSimpleExpressionWorker(node.whenFalse, depth + 1); + } + else if (kind === 188 + || kind === 187 + || kind === 186) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 175) { + return node.elements.length === 0; + } + else if (kind === 176) { + return node.properties.length === 0; + } + else if (kind === 179) { + if (!isSimpleExpressionWorker(node.expression, depth + 1)) { + return false; + } + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + if (!isSimpleExpressionWorker(argument, depth + 1)) { + return false; + } + } + return true; + } + } + return false; + } + var syntaxKindCache = ts.createMap(); + function formatSyntaxKind(kind) { + var syntaxKindEnum = ts.SyntaxKind; + if (syntaxKindEnum) { + if (syntaxKindCache[kind]) { + return syntaxKindCache[kind]; + } + for (var name_9 in syntaxKindEnum) { + if (syntaxKindEnum[name_9] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + } + } + } + else { + return kind.toString(); + } + } + ts.formatSyntaxKind = formatSyntaxKind; + function movePos(pos, value) { + return ts.positionIsSynthesized(pos) ? -1 : pos + value; + } + ts.movePos = movePos; + function createRange(pos, end) { + return { pos: pos, end: end }; + } + ts.createRange = createRange; + function moveRangeEnd(range, end) { + return createRange(range.pos, end); + } + ts.moveRangeEnd = moveRangeEnd; + function moveRangePos(range, pos) { + return createRange(pos, range.end); + } + ts.moveRangePos = moveRangePos; + function moveRangePastDecorators(node) { + return node.decorators && node.decorators.length > 0 + ? moveRangePos(node, node.decorators.end) + : node; + } + ts.moveRangePastDecorators = moveRangePastDecorators; + function moveRangePastModifiers(node) { + return node.modifiers && node.modifiers.length > 0 + ? moveRangePos(node, node.modifiers.end) + : moveRangePastDecorators(node); + } + ts.moveRangePastModifiers = moveRangePastModifiers; + function isCollapsedRange(range) { + return range.pos === range.end; + } + ts.isCollapsedRange = isCollapsedRange; + function collapseRangeToStart(range) { + return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); + } + ts.collapseRangeToStart = collapseRangeToStart; + function collapseRangeToEnd(range) { + return isCollapsedRange(range) ? range : moveRangePos(range, range.end); + } + ts.collapseRangeToEnd = collapseRangeToEnd; + function createTokenRange(pos, token) { + return createRange(pos, pos + ts.tokenToString(token).length); + } + ts.createTokenRange = createTokenRange; + function rangeIsOnSingleLine(range, sourceFile) { + return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); + } + ts.rangeIsOnSingleLine = rangeIsOnSingleLine; + function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; + function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, range2.end, sourceFile); + } + ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; + function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); + } + ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; + function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function positionsAreOnSameLine(pos1, pos2, sourceFile) { + return pos1 === pos2 || + getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); + } + ts.positionsAreOnSameLine = positionsAreOnSameLine; + function getStartPositionOfRange(range, sourceFile) { + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + } + ts.getStartPositionOfRange = getStartPositionOfRange; + 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 235: + externalImports.push(node); + break; + case 234: + if (node.moduleReference.kind === 245) { + externalImports.push(node); + } + break; + case 241: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStarsToExportValues = true; + } + else { + externalImports.push(node); + } + } + else { + for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { + var specifier = _c[_b]; + 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 240: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + case 205: + 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 225: + 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 226: + 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; + } + } + 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 229: + case 230: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; + function getInitializedVariables(node) { + return ts.filter(node.declarations, isInitializedVariable); + } + ts.getInitializedVariables = getInitializedVariables; + function isInitializedVariable(node) { + return node.initializer !== undefined; + } + function isMergedWithClass(node) { + if (node.symbol) { + for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 226 && declaration !== node) { + return true; + } + } + } + return false; + } + ts.isMergedWithClass = isMergedWithClass; + function isFirstDeclarationOfKind(node, kind) { + return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; + } + ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; + function isNodeArray(array) { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); + } + ts.isNodeArray = isNodeArray; + function isNoSubstitutionTemplateLiteral(node) { + return node.kind === 12; + } + ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 12; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 12; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isLiteralExpression(node) { + return isLiteralKind(node.kind); + } + ts.isLiteralExpression = isLiteralExpression; + function isTemplateLiteralKind(kind) { + return 12 <= kind && kind <= 15; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateHead(node) { + return node.kind === 13; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 14 + || kind === 15; + } + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; + function isIdentifier(node) { + return node.kind === 70; + } + ts.isIdentifier = isIdentifier; + function isGeneratedIdentifier(node) { + return isIdentifier(node) && node.autoGenerateKind > 0; + } + ts.isGeneratedIdentifier = isGeneratedIdentifier; + function isModifier(node) { + return isModifierKind(node.kind); + } + ts.isModifier = isModifier; + function isQualifiedName(node) { + return node.kind === 141; + } + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 142; + } + ts.isComputedPropertyName = isComputedPropertyName; + function isEntityName(node) { + var kind = node.kind; + return kind === 141 + || kind === 70; + } + ts.isEntityName = isEntityName; + function isPropertyName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9 + || kind === 8 + || kind === 142; + } + ts.isPropertyName = isPropertyName; + function isModuleName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9; + } + ts.isModuleName = isModuleName; + function isBindingName(node) { + var kind = node.kind; + return kind === 70 + || kind === 172 + || kind === 173; + } + ts.isBindingName = isBindingName; + function isTypeParameter(node) { + return node.kind === 143; + } + ts.isTypeParameter = isTypeParameter; + function isParameter(node) { + return node.kind === 144; + } + ts.isParameter = isParameter; + function isDecorator(node) { + return node.kind === 145; + } + ts.isDecorator = isDecorator; + function isMethodDeclaration(node) { + return node.kind === 149; + } + ts.isMethodDeclaration = isMethodDeclaration; + function isClassElement(node) { + var kind = node.kind; + return kind === 150 + || kind === 147 + || kind === 149 + || kind === 151 + || kind === 152 + || kind === 155 + || kind === 203; + } + ts.isClassElement = isClassElement; + function isObjectLiteralElementLike(node) { + var kind = node.kind; + return kind === 257 + || kind === 258 + || kind === 259 + || kind === 149 + || kind === 151 + || kind === 152 + || kind === 244; + } + ts.isObjectLiteralElementLike = isObjectLiteralElementLike; + function isTypeNodeKind(kind) { + return (kind >= 156 && kind <= 171) + || kind === 118 + || kind === 132 + || kind === 121 + || kind === 134 + || kind === 135 + || kind === 104 + || kind === 129 + || kind === 199; + } + function isTypeNode(node) { + return isTypeNodeKind(node.kind); + } + ts.isTypeNode = isTypeNode; + function isBindingPattern(node) { + if (node) { + var kind = node.kind; + return kind === 173 + || kind === 172; + } + return false; + } + ts.isBindingPattern = isBindingPattern; + function isBindingElement(node) { + return node.kind === 174; + } + ts.isBindingElement = isBindingElement; + function isArrayBindingElement(node) { + var kind = node.kind; + return kind === 174 + || kind === 198; + } + ts.isArrayBindingElement = isArrayBindingElement; + function isArrayLiteralExpression(node) { + return node.kind === 175; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 176; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; + function isPropertyAccessExpression(node) { + return node.kind === 177; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 178; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isBinaryExpression(node) { + return node.kind === 192; + } + ts.isBinaryExpression = isBinaryExpression; + function isConditionalExpression(node) { + return node.kind === 193; + } + ts.isConditionalExpression = isConditionalExpression; + function isCallExpression(node) { + return node.kind === 179; + } + ts.isCallExpression = isCallExpression; + function isTemplateLiteral(node) { + var kind = node.kind; + return kind === 194 + || kind === 12; + } + ts.isTemplateLiteral = isTemplateLiteral; + function isSpreadExpression(node) { + return node.kind === 196; + } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 199; + } + ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; + function isLeftHandSideExpressionKind(kind) { + return kind === 177 + || kind === 178 + || kind === 180 + || kind === 179 + || kind === 246 + || kind === 247 + || kind === 181 + || kind === 175 + || kind === 183 + || kind === 176 + || kind === 197 + || kind === 184 + || kind === 70 + || kind === 11 + || kind === 8 + || kind === 9 + || kind === 12 + || kind === 194 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 201; + } + function isLeftHandSideExpression(node) { + return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isUnaryExpressionKind(kind) { + return kind === 190 + || kind === 191 + || kind === 186 + || kind === 187 + || kind === 188 + || kind === 189 + || kind === 182 + || isLeftHandSideExpressionKind(kind); + } + function isUnaryExpression(node) { + return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isUnaryExpression = isUnaryExpression; + function isExpressionKind(kind) { + return kind === 193 + || kind === 195 + || kind === 185 + || kind === 192 + || kind === 196 + || kind === 200 + || kind === 198 + || isUnaryExpressionKind(kind); + } + function isExpression(node) { + return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isExpression = isExpression; + function isAssertionExpression(node) { + var kind = node.kind; + return kind === 182 + || kind === 200; + } + ts.isAssertionExpression = isAssertionExpression; + function isPartiallyEmittedExpression(node) { + return node.kind === 293; + } + ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; + function isNotEmittedStatement(node) { + return node.kind === 292; + } + ts.isNotEmittedStatement = isNotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node) { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); + } + ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; + function isOmittedExpression(node) { + return node.kind === 198; + } + ts.isOmittedExpression = isOmittedExpression; + function isTemplateSpan(node) { + return node.kind === 202; + } + ts.isTemplateSpan = isTemplateSpan; + function isBlock(node) { + return node.kind === 204; + } + ts.isBlock = isBlock; + function isConciseBody(node) { + return isBlock(node) + || isExpression(node); + } + ts.isConciseBody = isConciseBody; + function isFunctionBody(node) { + return isBlock(node); + } + ts.isFunctionBody = isFunctionBody; + function isForInitializer(node) { + return isVariableDeclarationList(node) + || isExpression(node); + } + ts.isForInitializer = isForInitializer; + function isVariableDeclaration(node) { + return node.kind === 223; + } + ts.isVariableDeclaration = isVariableDeclaration; + function isVariableDeclarationList(node) { + return node.kind === 224; + } + ts.isVariableDeclarationList = isVariableDeclarationList; + function isCaseBlock(node) { + return node.kind === 232; + } + ts.isCaseBlock = isCaseBlock; + function isModuleBody(node) { + var kind = node.kind; + return kind === 231 + || kind === 230; + } + ts.isModuleBody = isModuleBody; + function isImportEqualsDeclaration(node) { + return node.kind === 234; + } + ts.isImportEqualsDeclaration = isImportEqualsDeclaration; + function isImportClause(node) { + return node.kind === 236; + } + ts.isImportClause = isImportClause; + function isNamedImportBindings(node) { + var kind = node.kind; + return kind === 238 + || kind === 237; + } + ts.isNamedImportBindings = isNamedImportBindings; + function isImportSpecifier(node) { + return node.kind === 239; + } + ts.isImportSpecifier = isImportSpecifier; + function isNamedExports(node) { + return node.kind === 242; + } + ts.isNamedExports = isNamedExports; + function isExportSpecifier(node) { + return node.kind === 243; + } + ts.isExportSpecifier = isExportSpecifier; + function isModuleOrEnumDeclaration(node) { + return node.kind === 230 || node.kind === 229; + } + ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; + function isDeclarationKind(kind) { + return kind === 185 + || kind === 174 + || kind === 226 + || kind === 197 + || kind === 150 + || kind === 229 + || kind === 260 + || kind === 243 + || kind === 225 + || kind === 184 + || kind === 151 + || kind === 236 + || kind === 234 + || kind === 239 + || kind === 227 + || kind === 149 + || kind === 148 + || kind === 230 + || kind === 233 + || kind === 237 + || kind === 144 + || kind === 257 + || kind === 147 + || kind === 146 + || kind === 152 + || kind === 258 + || kind === 228 + || kind === 143 + || kind === 223 + || kind === 284; + } + function isDeclarationStatementKind(kind) { + return kind === 225 + || kind === 244 + || kind === 226 + || kind === 227 + || kind === 228 + || kind === 229 + || kind === 230 + || kind === 235 + || kind === 234 + || kind === 241 + || kind === 240 + || kind === 233; + } + function isStatementKindButNotDeclarationKind(kind) { + return kind === 215 + || kind === 214 + || kind === 222 + || kind === 209 + || kind === 207 + || kind === 206 + || kind === 212 + || kind === 213 + || kind === 211 + || kind === 208 + || kind === 219 + || kind === 216 + || kind === 218 + || kind === 220 + || kind === 221 + || kind === 205 + || kind === 210 + || kind === 217 + || kind === 292 + || kind === 295 + || kind === 294; + } + function isDeclaration(node) { + return isDeclarationKind(node.kind); + } + ts.isDeclaration = isDeclaration; + function isDeclarationStatement(node) { + return isDeclarationStatementKind(node.kind); + } + ts.isDeclarationStatement = isDeclarationStatement; + function isStatementButNotDeclaration(node) { + return isStatementKindButNotDeclarationKind(node.kind); + } + ts.isStatementButNotDeclaration = isStatementButNotDeclaration; + function isStatement(node) { + var kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === 204; + } + ts.isStatement = isStatement; + function isModuleReference(node) { + var kind = node.kind; + return kind === 245 + || kind === 141 + || kind === 70; + } + ts.isModuleReference = isModuleReference; + function isJsxOpeningElement(node) { + return node.kind === 248; + } + ts.isJsxOpeningElement = isJsxOpeningElement; + function isJsxClosingElement(node) { + return node.kind === 249; + } + ts.isJsxClosingElement = isJsxClosingElement; + function isJsxTagNameExpression(node) { + var kind = node.kind; + return kind === 98 + || kind === 70 + || kind === 177; + } + ts.isJsxTagNameExpression = isJsxTagNameExpression; + function isJsxChild(node) { + var kind = node.kind; + return kind === 246 + || kind === 252 + || kind === 247 + || kind === 10; + } + ts.isJsxChild = isJsxChild; + function isJsxAttributeLike(node) { + var kind = node.kind; + return kind === 250 + || kind === 251; + } + ts.isJsxAttributeLike = isJsxAttributeLike; + function isJsxSpreadAttribute(node) { + return node.kind === 251; + } + ts.isJsxSpreadAttribute = isJsxSpreadAttribute; + function isJsxAttribute(node) { + return node.kind === 250; + } + ts.isJsxAttribute = isJsxAttribute; + function isStringLiteralOrJsxExpression(node) { + var kind = node.kind; + return kind === 9 + || kind === 252; + } + ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isCaseOrDefaultClause(node) { + var kind = node.kind; + return kind === 253 + || kind === 254; + } + ts.isCaseOrDefaultClause = isCaseOrDefaultClause; + function isHeritageClause(node) { + return node.kind === 255; + } + ts.isHeritageClause = isHeritageClause; + function isCatchClause(node) { + return node.kind === 256; + } + ts.isCatchClause = isCatchClause; + function isPropertyAssignment(node) { + return node.kind === 257; + } + ts.isPropertyAssignment = isPropertyAssignment; + function isShorthandPropertyAssignment(node) { + return node.kind === 258; + } + ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; + function isEnumMember(node) { + return node.kind === 260; + } + ts.isEnumMember = isEnumMember; + function isSourceFile(node) { + return node.kind === 261; + } + ts.isSourceFile = isSourceFile; + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); + } + ts.isWatchSet = isWatchSet; +})(ts || (ts = {})); +(function (ts) { + function getDefaultLibFileName(options) { + switch (options.target) { + case 5: + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 143) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; + function isParameterPropertyDeclaration(node) { + return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); + } + ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 174 || ts.isBindingPattern(node))) { + node = node.parent; + } + return node; + } + function getCombinedModifierFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = ts.getModifierFlags(node); + if (node.kind === 223) { + node = node.parent; + } + if (node && node.kind === 224) { + flags |= ts.getModifierFlags(node); + node = node.parent; + } + if (node && node.kind === 205) { + flags |= ts.getModifierFlags(node); + } + return flags; + } + ts.getCombinedModifierFlags = getCombinedModifierFlags; + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 223) { + node = node.parent; + } + if (node && node.kind === 224) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 205) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; +})(ts || (ts = {})); +var ts; (function (ts) { var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 + var ConstructorForKind = kind === 261 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -9781,7 +10777,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; } @@ -9793,12 +10789,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; @@ -9808,16 +10800,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; @@ -9835,7 +10827,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; @@ -9855,7 +10847,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; @@ -9873,7 +10865,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; @@ -9892,7 +10884,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; @@ -9910,7 +10902,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(172, location); node.elements = createNodeArray(elements); return node; } @@ -9923,7 +10915,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169, location); + var node = createNode(173, location); node.elements = createNodeArray(elements); return node; } @@ -9936,7 +10928,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170, location); + var node = createNode(174, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -9952,7 +10944,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171, location); + var node = createNode(175, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -9968,7 +10960,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172, location); + var node = createNode(176, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -9984,7 +10976,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173, location, flags); + var node = createNode(177, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10001,7 +10993,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174, location); + var node = createNode(178, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10015,7 +11007,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(179, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10032,7 +11024,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176, location, flags); + var node = createNode(180, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10047,7 +11039,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177, location); + var node = createNode(181, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10061,7 +11053,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179, location); + var node = createNode(183, location); node.expression = expression; return node; } @@ -10074,7 +11066,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(184, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10093,7 +11085,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(185, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10111,7 +11103,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182, location); + var node = createNode(186, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10124,7 +11116,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183, location); + var node = createNode(187, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10137,7 +11129,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184, location); + var node = createNode(188, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10150,7 +11142,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185, location); + var node = createNode(189, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10163,7 +11155,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186, location); + var node = createNode(190, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10177,7 +11169,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187, location); + var node = createNode(191, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10193,7 +11185,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(192, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10208,7 +11200,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189, location); + var node = createNode(193, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10225,7 +11217,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190, location); + var node = createNode(194, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10239,7 +11231,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191, location); + var node = createNode(195, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10253,7 +11245,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192, location); + var node = createNode(196, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10266,7 +11258,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193, location); + var node = createNode(197, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10284,12 +11276,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194, location); + var node = createNode(198, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195, location); + var node = createNode(199, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10303,7 +11295,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(198, location); + var node = createNode(202, location); node.expression = expression; node.literal = literal; return node; @@ -10317,7 +11309,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(200, location, flags); + var block = createNode(204, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10333,7 +11325,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201, location, flags); + var node = createNode(205, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10348,7 +11340,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(224, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10361,7 +11353,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(223, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10376,11 +11368,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202, location); + return createNode(206, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203, location, flags); + var node = createNode(207, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10393,7 +11385,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204, location); + var node = createNode(208, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -10408,7 +11400,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205, location); + var node = createNode(209, location); node.statement = statement; node.expression = expression; return node; @@ -10422,7 +11414,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206, location); + var node = createNode(210, location); node.expression = expression; node.statement = statement; return node; @@ -10436,7 +11428,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207, location, undefined); + var node = createNode(211, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -10452,7 +11444,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(212, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10467,7 +11459,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10482,7 +11474,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210, location); + var node = createNode(214, location); if (label) { node.label = label; } @@ -10497,7 +11489,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -10512,7 +11504,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -10525,7 +11517,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213, location); + var node = createNode(217, location); node.expression = expression; node.statement = statement; return node; @@ -10539,7 +11531,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214, location); + var node = createNode(218, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -10553,7 +11545,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215, location); + var node = createNode(219, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -10567,7 +11559,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216, location); + var node = createNode(220, location); node.expression = expression; return node; } @@ -10580,7 +11572,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217, location); + var node = createNode(221, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -10595,7 +11587,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228, location); + var node = createNode(232, location); node.clauses = createNodeArray(clauses); return node; } @@ -10608,7 +11600,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(225, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10628,7 +11620,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222, location); + var node = createNode(226, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10646,7 +11638,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231, location); + var node = createNode(235, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -10662,7 +11654,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232, location); + var node = createNode(236, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -10676,7 +11668,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233, location); + var node = createNode(237, location); node.name = name; return node; } @@ -10689,7 +11681,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -10702,7 +11694,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235, location); + var node = createNode(239, location); node.propertyName = propertyName; node.name = name; return node; @@ -10716,7 +11708,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236, location); + var node = createNode(240, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -10732,7 +11724,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -10748,7 +11740,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238, location); + var node = createNode(242, location); node.elements = createNodeArray(elements); return node; } @@ -10761,7 +11753,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239, location); + var node = createNode(243, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -10775,7 +11767,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242, location); + var node = createNode(246, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -10790,7 +11782,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(247, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -10804,7 +11796,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -10818,7 +11810,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); + var node = createNode(249, location); node.tagName = tagName; return node; } @@ -10831,7 +11823,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); + var node = createNode(250, location); node.name = name; node.initializer = initializer; return node; @@ -10845,7 +11837,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); + var node = createNode(251, location); node.expression = expression; return node; } @@ -10858,7 +11850,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -10871,7 +11863,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(251, location); + var node = createNode(255, location); node.token = token; node.types = createNodeArray(types); return node; @@ -10885,7 +11877,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249, location); + var node = createNode(253, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -10899,7 +11891,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250, location); + var node = createNode(254, location); node.statements = createNodeArray(statements); return node; } @@ -10912,7 +11904,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); + var node = createNode(256, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -10926,7 +11918,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); + var node = createNode(257, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10941,12 +11933,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); + var node = createNode(258, 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(259, 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); @@ -10954,9 +11952,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(261, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11018,13 +12023,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(287, original); + var node = createNode(292, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + function createEndOfDeclarationMarker(original) { + var node = createNode(295); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + function createMergeDeclarationMarker(original) { + var node = createNode(294); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); + var node = createNode(293, location || original); node.expression = expression; node.original = original; return node; @@ -11096,10 +12115,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 @@ -11132,10 +12147,23 @@ var ts; function createReactNamespace(reactNamespace, parent) { var react = createIdentifier(reactNamespace || "React"); react.flags &= ~8; - react.parent = parent; + 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); @@ -11155,9 +12183,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); } @@ -11229,13 +12269,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([ @@ -11244,20 +12284,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 @@ -11283,13 +12323,13 @@ var ts; case 8: case 9: return false; - case 171: + case 175: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172: + case 176: return target.properties.length > 0; default: return true; @@ -11309,7 +12349,7 @@ var ts; } else { switch (callee.kind) { - case 173: { + case 177: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11320,7 +12360,7 @@ var ts; } break; } - case 174: { + case 178: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -11370,14 +12410,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 257: return createExpressionForPropertyAssignment(property, receiver); - case 254: + case 258: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148: + case 149: return createExpressionForMethodDeclaration(property, receiver); } } @@ -11418,6 +12458,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"; } @@ -11479,7 +12572,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 179) { + if (skipped.kind === 183) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -11488,15 +12581,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(192, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, 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 === 195) { return false; } return true; @@ -11535,7 +12628,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.kind === 192 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -11552,9 +12645,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175: + case 179: return createParen(expression); - case 176: + case 180: return emittedExpression.arguments ? expression : createParen(expression); @@ -11565,7 +12658,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && (emittedExpression.kind !== 180 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -11603,7 +12696,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(192, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -11614,7 +12707,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 || kind === 181) { + if (kind === 184 || kind === 185) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -11622,7 +12715,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { return createParen(expression, expression); } } @@ -11640,21 +12733,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187: + case 191: node = node.operand; continue; - case 188: + case 192: node = node.left; continue; - case 189: + case 193: node = node.condition; continue; - case 175: - case 174: - case 173: + case 179: + case 178: + case 177: node = node.expression; continue; - case 288: + case 293: node = node.expression; continue; } @@ -11663,19 +12756,12 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172) { + if (emittedBody.kind === 176) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; - (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; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -11695,7 +12781,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179) { + while (node.kind === 183) { node = node.expression; } return node; @@ -11709,7 +12795,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { + while (node.kind === 293) { node = node.expression; } return node; @@ -11765,7 +12851,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { + if (node.kind === 261) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -11855,13 +12941,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_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 === 235 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 && node.moduleSpecifier) { + if (node.kind === 241 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -11899,6 +12985,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 === 185); + 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 !== 185) { + 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) { @@ -11907,13 +13208,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256) { + if (kind === 261) { 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 { @@ -11949,26 +13250,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 258: 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 259: + return visitNode(cbNode, node.expression); + case 144: + case 147: case 146: - case 145: - case 253: - case 219: - case 170: + case 257: + case 223: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -11977,24 +13280,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 184: + case 225: + case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12005,308 +13308,318 @@ 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.readonlyToken) || + visitNode(cbNode, node.typeParameter) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type); case 171: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.literal); case 172: - return visitNodes(cbNodes, node.properties); case 173: + return visitNodes(cbNodes, node.elements); + case 175: + return visitNodes(cbNodes, node.elements); + case 176: + return visitNodes(cbNodes, node.properties); + case 177: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174: + case 178: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175: - case 176: + case 179: + case 180: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177: + case 181: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178: + case 182: 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 187: - return visitNode(cbNode, node.operand); + return visitNode(cbNode, node.expression); case 188: + return visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.operand); + case 195: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 189: + return visitNode(cbNode, node.expression); + case 191: + return visitNode(cbNode, node.operand); + case 192: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196: + case 200: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197: + case 201: return visitNode(cbNode, node.expression); - case 189: + case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192: + case 196: return visitNode(cbNode, node.expression); - case 200: - case 227: + case 204: + case 231: return visitNodes(cbNodes, node.statements); - case 256: + case 261: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201: + case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220: + case 224: return visitNodes(cbNodes, node.declarations); - case 203: + case 207: return visitNode(cbNode, node.expression); - case 204: + case 208: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205: + case 209: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207: + case 211: 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); case 212: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 213: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 228: - return visitNodes(cbNodes, node.clauses); - case 249: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 250: - return visitNodes(cbNodes, node.statements); case 215: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.label); case 216: return visitNode(cbNode, node.expression); case 217: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 232: + return visitNodes(cbNodes, node.clauses); + case 253: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 254: + return visitNodes(cbNodes, node.statements); + case 219: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 220: + return visitNode(cbNode, node.expression); + case 221: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252: + case 256: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144: + case 145: return visitNode(cbNode, node.expression); - case 222: - case 193: + case 226: + case 197: 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: + case 227: 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: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 225: + case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255: + case 260: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 234: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229: - return visitNode(cbNode, node.name); case 233: return visitNode(cbNode, node.name); - case 234: - case 238: - return visitNodes(cbNodes, node.elements); case 237: + return visitNode(cbNode, node.name); + case 238: + case 242: + return visitNodes(cbNodes, node.elements); + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235: case 239: + case 243: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236: + case 240: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190: + case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198: + case 202: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141: + case 142: return visitNode(cbNode, node.expression); - case 251: + case 255: return visitNodes(cbNodes, node.types); - case 195: + case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241: + case 245: return visitNode(cbNode, node.expression); - case 240: + case 244: return visitNodes(cbNodes, node.decorators); - case 242: + case 246: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243: - case 244: + case 247: + case 248: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246: + case 250: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247: + case 251: return visitNode(cbNode, node.expression); - case 248: + case 252: return visitNode(cbNode, node.expression); - case 245: + case 249: 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); - case 268: - return visitNode(cbNode, node.type); - case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); - case 271: - return visitNode(cbNode, node.type); - case 272: return visitNode(cbNode, node.type); case 266: + return visitNodes(cbNodes, node.types); + case 267: + return visitNodes(cbNodes, node.types); + case 265: + return visitNode(cbNode, node.elementType); + case 269: + return visitNode(cbNode, node.type); + case 268: + return visitNode(cbNode, node.type); + case 270: + return visitNode(cbNode, node.literal); + case 272: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 273: + return visitNode(cbNode, node.type); + case 274: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.type); + case 276: + return visitNode(cbNode, node.type); + case 277: + return visitNode(cbNode, node.type); + case 271: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273: + case 278: return visitNodes(cbNodes, node.tags); - case 275: + case 280: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276: + case 281: return visitNode(cbNode, node.typeExpression); - case 277: + case 282: return visitNode(cbNode, node.typeExpression); - case 278: + case 283: return visitNodes(cbNodes, node.typeParameters); - case 279: + case 284: return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281: + case 286: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: + case 285: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288: + case 293: return visitNode(cbNode, node.expression); - case 282: + case 287: return visitNode(cbNode, node.literal); } } @@ -12320,6 +13633,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; } @@ -12342,8 +13659,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; @@ -12367,6 +13684,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; } @@ -12382,7 +13708,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); @@ -12457,7 +13783,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -12477,17 +13803,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) { @@ -12509,41 +13835,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; @@ -12684,7 +14010,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); } @@ -12704,7 +14030,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288; + node.flags |= 1048576; } return node; } @@ -12766,7 +14092,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); @@ -12836,9 +14162,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); @@ -12853,29 +14181,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'."); @@ -12919,7 +14247,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; @@ -12927,31 +14255,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; } } @@ -12968,7 +14297,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; @@ -13019,7 +14348,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 1540096; + var nodeContextFlags = node.flags & 3080192; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -13051,10 +14380,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: @@ -13066,14 +14397,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 203: return true; - case 148: + case 149: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -13085,8 +14416,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249: - case 250: + case 253: + case 254: return true; } } @@ -13095,65 +14426,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221: - case 201: - case 200: + case 225: + case 205: case 204: - case 203: + case 208: + case 207: + case 220: case 216: - case 212: + case 218: + case 215: case 214: + case 212: + case 213: case 211: case 210: - case 208: - case 209: - case 207: - case 206: - case 213: - case 202: case 217: - case 215: - case 205: - case 218: - case 231: - case 230: - case 237: - case 236: - case 226: + case 206: + case 221: + case 219: + case 209: case 222: - case 223: - case 225: - case 224: + case 235: + case 234: + case 241: + case 240: + case 230: + case 226: + case 227: + case 229: + case 228: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255; + return node.kind === 260; } 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 !== 223) { 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; @@ -13173,6 +14504,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; @@ -13184,17 +14516,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; } } ; @@ -13248,7 +14580,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); @@ -13265,7 +14597,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190); + var template = createNode(194); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -13277,7 +14609,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198); + var span = createNode(202); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -13325,33 +14657,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()) { @@ -13365,7 +14697,7 @@ var ts; } function parseTypeParameters() { if (token() === 26) { - return parseBracketedList(17, parseTypeParameter, 26, 28); + return parseBracketedList(18, parseTypeParameter, 26, 28); } } function parseParameterType() { @@ -13378,7 +14710,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(); @@ -13438,7 +14770,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -13478,7 +14810,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); @@ -13490,7 +14822,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; @@ -13499,7 +14831,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; @@ -13539,10 +14871,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(); @@ -13556,7 +14888,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(160); + var node = createNode(161); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -13571,13 +14903,40 @@ var ts; } return members; } + function isStartOfMappedType() { + nextToken(); + if (token() === 130) { + nextToken(); + } + return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; + } + function parseMappedTypeParameter() { + var node = createNode(143); + node.name = parseIdentifier(); + parseExpected(91); + node.constraint = parseType(); + return finishNode(node); + } + function parseMappedType() { + var node = createNode(170); + parseExpected(16); + node.readonlyToken = parseOptionalToken(130); + parseExpected(20); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(21); + node.questionToken = parseOptionalToken(54); + node.type = parseTypeAnnotation(); + parseSemicolon(); + parseExpected(17); + return finishNode(node); + } 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); @@ -13585,7 +14944,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -13596,7 +14955,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167); + var node = createNode(171); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -13607,12 +14966,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: @@ -13637,7 +14996,7 @@ var ts; case 102: return parseTypeQuery(); case 16: - return parseTypeLiteral(); + return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); case 20: return parseTupleType(); case 18: @@ -13649,16 +15008,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: @@ -13683,13 +15042,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) { @@ -13705,10 +15087,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) { @@ -13754,7 +15136,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); @@ -13771,14 +15153,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(); } @@ -13897,7 +15279,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191); + var node = createNode(195); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -13913,13 +15295,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(185, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181, identifier.pos); + node = createNode(185, 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); @@ -14053,7 +15435,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181); + var node = createNode(185); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -14085,7 +15467,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(189, leftOperand.pos); + var node = createNode(193, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14098,7 +15480,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) { @@ -14176,39 +15558,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188, left.pos); + var node = createNode(192, 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(200, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186); + var node = createNode(190); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182); + var node = createNode(186); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183); + var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184); + var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14223,7 +15605,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185); + var node = createNode(189); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14239,7 +15621,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178) { + if (simpleUnaryExpression.kind === 182) { 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 { @@ -14292,7 +15674,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(186); + var node = createNode(190); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14304,7 +15686,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(191, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14327,7 +15709,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(173, expression.pos); + var node = createNode(177, 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); @@ -14349,8 +15731,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 === 248) { + var node = createNode(246, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14360,14 +15742,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243); + ts.Debug.assert(opening.kind === 247); 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(192, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -14420,7 +15802,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(244, fullStart); + node = createNode(248, fullStart); scanJsxText(); } else { @@ -14432,7 +15814,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(243, fullStart); + node = createNode(247, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14443,7 +15825,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(177, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14451,7 +15833,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248); + var node = createNode(252); parseExpected(16); if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); @@ -14470,7 +15852,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246); + var node = createNode(250); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -14485,7 +15867,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247); + var node = createNode(251); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -14493,7 +15875,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245); + var node = createNode(249); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -14506,7 +15888,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178); + var node = createNode(182); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -14517,7 +15899,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(177, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14525,13 +15907,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197, expression.pos); + var nonNullExpression = createNode(201, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(174, expression.pos); + var indexedAccess = createNode(178, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -14545,7 +15927,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(177, expression.pos); + var tagExpression = createNode(181, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -14564,7 +15946,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(179, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -14572,7 +15954,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(179, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14591,7 +15973,7 @@ var ts; if (!parseOptional(26)) { return undefined; } - var typeArguments = parseDelimitedList(18, parseType); + var typeArguments = parseDelimitedList(19, parseType); if (!parseExpected(28)) { return undefined; } @@ -14667,28 +16049,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179); + var node = createNode(183); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192); + var node = createNode(196); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(194) : + token() === 25 ? createNode(198) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171); + var node = createNode(175); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14699,15 +16081,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(259, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -14723,7 +16111,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254, fullStart); + var shorthandDeclaration = createNode(258, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14734,7 +16122,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253, fullStart); + var propertyAssignment = createNode(257, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14744,7 +16132,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172); + var node = createNode(176); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14758,7 +16146,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(180); + var node = createNode(184); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -14780,7 +16168,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176); + var node = createNode(180); parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -14790,7 +16178,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200); + var node = createNode(204); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14821,12 +16209,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202); + var node = createNode(206); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(204); + var node = createNode(208); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14836,7 +16224,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205); + var node = createNode(209); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14847,7 +16235,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206); + var node = createNode(210); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14870,21 +16258,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(208, pos); + var forInStatement = createNode(212, 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(213, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207, pos); + var forStatement = createNode(211, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14902,7 +16290,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 ? 71 : 76); + parseExpected(kind === 215 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14910,7 +16298,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212); + var node = createNode(216); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14919,7 +16307,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213); + var node = createNode(217); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14928,7 +16316,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249); + var node = createNode(253); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14936,7 +16324,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250); + var node = createNode(254); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14946,12 +16334,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214); + var node = createNode(218); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(228, scanner.getStartPos()); + var caseBlock = createNode(232, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14959,14 +16347,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(216); + var node = createNode(220); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(217); + var node = createNode(221); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14977,7 +16365,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252); + var result = createNode(256); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14987,7 +16375,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218); + var node = createNode(222); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14996,13 +16384,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(219, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203, fullStart); + var expressionStatement = createNode(207, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15031,10 +16419,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: @@ -15042,13 +16430,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: @@ -15106,16 +16494,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(); @@ -15154,9 +16542,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(210); + return parseBreakOrContinueStatement(214); case 71: - return parseBreakOrContinueStatement(211); + return parseBreakOrContinueStatement(215); case 95: return parseReturnStatement(); case 106: @@ -15175,9 +16563,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: @@ -15188,8 +16576,8 @@ var ts; case 113: case 116: case 114: - case 129: - case 138: + case 130: + case 139: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15212,13 +16600,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); @@ -15235,7 +16623,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15256,16 +16644,17 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(194); + return createNode(198); } - var node = createNode(170); + var node = createNode(174); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170); + var node = createNode(174); + node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55) { @@ -15280,14 +16669,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168); + var node = createNode(172); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169); + var node = createNode(173); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -15306,7 +16695,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219); + var node = createNode(223); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15315,7 +16704,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220); + var node = createNode(224); switch (token()) { case 103: break; @@ -15329,7 +16718,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15344,7 +16733,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15352,7 +16741,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -15365,7 +16754,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); @@ -15374,7 +16763,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; @@ -15387,7 +16776,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; @@ -15395,7 +16784,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)); } @@ -15428,7 +16817,7 @@ var ts; case 111: case 112: case 114: - case 129: + case 130: return true; default: return false; @@ -15457,7 +16846,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()) { @@ -15480,7 +16869,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) { @@ -15537,7 +16926,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(199); + var result = createNode(203); nextToken(); return finishNode(result); } @@ -15562,16 +16951,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_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, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -15600,13 +16989,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(255); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -15615,10 +17004,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195); + var node = createNode(199); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } @@ -15629,7 +17018,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -15640,10 +17029,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135); + parseExpected(136); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -15652,13 +17041,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(255, scanner.getStartPos()); + var node = createNode(260, 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(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15673,7 +17062,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(231, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15684,7 +17073,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226, fullStart); + var node = createNode(230, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15696,10 +17085,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138) { + if (token() === 139) { node.name = parseIdentifier(); node.flags |= 512; } @@ -15716,14 +17105,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); } @@ -15731,7 +17120,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 && + return token() === 131 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -15741,13 +17130,13 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229, fullStart); + var exportDeclaration = createNode(233, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); - parseExpected(127); + parseExpected(128); exportDeclaration.name = parseIdentifier(); - parseExpected(24); + parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { @@ -15756,8 +17145,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(234, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15767,27 +17156,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(231, fullStart); + var importDeclaration = createNode(235, 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(236, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); } return finishNode(importClause); } @@ -15797,8 +17186,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(241); - parseExpected(130); + var node = createNode(245); + parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); parseExpected(19); @@ -15815,7 +17204,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(233); + var namespaceImport = createNode(237); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15823,14 +17212,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 === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(243); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235); + return parseImportOrExportSpecifier(239); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15849,23 +17238,23 @@ var ts; else { node.name = identifierName; } - if (kind === 235 && checkIdentifierIsKeyword) { + if (kind === 239 && 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(241, 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(242); + if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -15873,7 +17262,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(240, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15952,50 +17341,14 @@ 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 === 234 && node.moduleReference.kind === 245 + || node.kind === 235 + || node.kind === 240 + || node.kind === 241 ? node : undefined; }); } - var ParsingContext; - (function (ParsingContext) { - ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; - 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"; - })(ParsingContext || (ParsingContext = {})); - var Tristate; - (function (Tristate) { - Tristate[Tristate["False"] = 0] = "False"; - Tristate[Tristate["True"] = 1] = "True"; - Tristate[Tristate["Unknown"] = 2] = "Unknown"; - })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -16016,8 +17369,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(); @@ -16027,7 +17380,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(257, scanner.getTokenPos()); + var result = createNode(262, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -16038,12 +17391,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(261, type.pos); + var unionType = createNode(266, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(268, type.pos); + var optionalType = createNode(273, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -16054,20 +17407,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(260, type.pos); + var arrayType = createNode(265, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(263, type.pos); + var nullableType = createNode(268, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(264, type.pos); + var nonNullableType = createNode(269, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -16101,14 +17454,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: @@ -16119,30 +17472,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271); + var result = createNode(276); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270); + var result = createNode(275); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269); + var result = createNode(274); nextToken(); parseExpected(18); - result.parameters = parseDelimitedList(22, parseJSDocParameter); + result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19); if (token() === 55) { @@ -16152,7 +17505,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); @@ -16160,7 +17513,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267); + var result = createNode(272); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -16180,7 +17533,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(23, parseJSDocType); + var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28); @@ -16194,26 +17547,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(270); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264); + var result = createNode(269); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262); + var result = createNode(267); nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); + result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21); return finishNode(result); @@ -16225,7 +17578,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261); + var result = createNode(266); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -16241,12 +17594,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258); + var result = createNode(263); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282); + var result = createNode(287); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -16259,17 +17612,17 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(259, pos); + var result = createNode(264, pos); return finishNode(result); } else { - var result = createNode(263, pos); + var result = createNode(268, 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; @@ -16291,12 +17644,6 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; - var JSDocState; - (function (JSDocState) { - JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; - JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; - JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; - })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -16329,6 +17676,7 @@ var ts; } if (token() === 4) { state = 0; + indent = 0; nextJSDocToken(); } while (token() !== 1) { @@ -16408,7 +17756,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(273, start); + var result = createNode(278, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16515,7 +17863,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274, atToken.pos); + var result = createNode(279, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16570,7 +17918,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -16581,20 +17929,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 === 281; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276, atToken.pos); + var result = createNode(281, 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 === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -16609,7 +17957,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -16619,18 +17967,25 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279, atToken.pos); + var typedefTag = createNode(284, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; - typedefTag.name = parseJSDocIdentifierName(); + typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); + if (typedefTag.fullName) { + var rightNode = typedefTag.fullName; + while (rightNode.kind !== 70) { + rightNode = rightNode.body; + } + typedefTag.name = rightNode; + } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267) { + if (typeExpression.type.kind === 272) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_11 = jsDocTypeReference.name; - if (name_11.text === "Object") { + var name_17 = jsDocTypeReference.name; + if (name_17.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -16644,7 +17999,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(286, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16681,6 +18036,21 @@ var ts; scanner.setTextPos(resumePos); return finishNode(jsDocTypeLiteral); } + function parseJSDocTypeNameWithNamespace(flags) { + var pos = scanner.getTokenPos(); + var typeNameOrNamespaceName = parseJSDocIdentifierName(); + if (typeNameOrNamespaceName && parseOptional(22)) { + var jsDocNamespaceNode = createNode(230, pos); + jsDocNamespaceNode.flags |= flags; + jsDocNamespaceNode.name = typeNameOrNamespaceName; + jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); + return jsDocNamespaceNode; + } + if (typeNameOrNamespaceName && flags & 4) { + typeNameOrNamespaceName.isInJSDocNamespace = true; + } + return typeNameOrNamespaceName; + } } function tryParseChildTag(parentTag) { ts.Debug.assert(token() === 56); @@ -16701,29 +18071,32 @@ var ts; return true; case "prop": case "property": - if (!parentTag.jsDocPropertyTags) { - parentTag.jsDocPropertyTags = []; - } var propertyTag = parsePropertyTag(atToken, tagName); - parentTag.jsDocPropertyTags.push(propertyTag); - return true; + if (propertyTag) { + if (!parentTag.jsDocPropertyTags) { + parentTag.jsDocPropertyTags = []; + } + parentTag.jsDocPropertyTags.push(propertyTag); + return true; + } + return false; } 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 === 283; })) { 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_18 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_12) { + if (!name_18) { 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_18.pos); + typeParameter.name = name_18; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -16734,7 +18107,7 @@ var ts; break; } } - var result = createNode(278, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -17048,31 +18421,21 @@ var ts; } } } - var InvalidPosition; - (function (InvalidPosition) { - InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; - })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { - (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; function getModuleInstanceState(node) { - if (node.kind === 223 || node.kind === 224) { + if (node.kind === 227 || node.kind === 228) { 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 === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 227) { + else if (node.kind === 231) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17088,27 +18451,18 @@ var ts; }); return state_1; } - else if (node.kind === 226) { + else if (node.kind === 230) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } + else if (node.kind === 70 && node.isInJSDocNamespace) { + return 0; + } else { return 1; } } ts.getModuleInstanceState = getModuleInstanceState; - var ContainerFlags; - (function (ContainerFlags) { - ContainerFlags[ContainerFlags["None"] = 0] = "None"; - ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; - ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; - ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; - ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; - ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; - ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; - ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; - ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; - })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -17206,7 +18560,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 === 230)) { symbol.valueDeclaration = node; } } @@ -17216,7 +18570,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; @@ -17227,21 +18581,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 241: return "__export"; - case 236: + case 240: return node.isExportEquals ? "export=" : "default"; - case 188: + case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17253,20 +18607,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221: - case 222: + case 225: + case 226: return ts.hasModifier(node, 512) ? "default" : undefined; - case 269: + case 274: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143: - ts.Debug.assert(node.parent.kind === 269); + case 144: + ts.Debug.assert(node.parent.kind === 274); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279: + case 284: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 205) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -17310,7 +18664,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17330,7 +18684,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 === 243 || (node.kind === 234 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17338,7 +18692,11 @@ var ts; } } else { - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) { + var isJSDocTypedefInJSDocNamespace = node.kind === 284 && + node.name && + node.name.kind === 70 && + node.name.isInJSDocNamespace; + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793064 ? 2097152 : 0) | (symbolFlags & 1920 ? 4194304 : 0); @@ -17373,7 +18731,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(); } @@ -17389,13 +18747,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 === 261) { node.flags |= emitFlags; } if (isIIFE) { @@ -17430,6 +18788,7 @@ var ts; skipTransformFlagAggregation = true; bindChildrenWorker(node); skipTransformFlagAggregation = false; + subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); } else { var savedSubtreeTransformFlags = subtreeTransformFlags; @@ -17447,64 +18806,64 @@ var ts; return; } switch (node.kind) { - case 206: + case 210: bindWhileStatement(node); break; - case 205: + case 209: bindDoStatement(node); break; - case 207: + case 211: bindForStatement(node); break; - case 208: - case 209: + case 212: + case 213: bindForInOrForOfStatement(node); break; - case 204: + case 208: bindIfStatement(node); break; - case 212: case 216: + case 220: bindReturnOrThrow(node); break; - case 211: - case 210: + case 215: + case 214: bindBreakOrContinueStatement(node); break; - case 217: + case 221: bindTryStatement(node); break; - case 214: + case 218: bindSwitchStatement(node); break; - case 228: + case 232: bindCaseBlock(node); break; - case 249: + case 253: bindCaseClause(node); break; - case 215: + case 219: bindLabeledStatement(node); break; - case 186: + case 190: bindPrefixUnaryExpressionFlow(node); break; - case 187: + case 191: bindPostfixUnaryExpressionFlow(node); break; - case 188: + case 192: bindBinaryExpressionFlow(node); break; - case 182: + case 186: bindDeleteExpressionFlow(node); break; - case 189: + case 193: bindConditionalExpressionFlow(node); break; - case 219: + case 223: bindVariableDeclarationFlow(node); break; - case 175: + case 179: bindCallExpressionFlow(node); break; default: @@ -17516,15 +18875,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 177: return isNarrowableReference(expr); - case 175: - return hasNarrowableArgument(expr); case 179: + return hasNarrowableArgument(expr); + case 183: return isNarrowingExpression(expr.expression); - case 188: + case 192: return isNarrowingBinaryExpression(expr); - case 186: + case 190: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -17532,7 +18891,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 173 && isNarrowableReference(expr.expression); + expr.kind === 177 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17543,14 +18902,14 @@ var ts; } } } - if (expr.expression.kind === 173 && + if (expr.expression.kind === 177 && 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 === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -17571,9 +18930,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179: + case 183: return isNarrowableOperand(expr.expression); - case 188: + case 192: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -17667,33 +19026,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204: - case 206: - case 205: + case 208: + case 210: + case 209: return parent.expression === node; - case 207: - case 189: + case 211: + case 193: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179) { + if (node.kind === 183) { node = node.expression; } - else if (node.kind === 186 && node.operator === 50) { + else if (node.kind === 190 && node.operator === 50) { node = node.operand; } else { - return node.kind === 188 && (node.operatorToken.kind === 52 || + return node.kind === 192 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 || - node.parent.kind === 186 && + while (node.parent.kind === 183 || + node.parent.kind === 190 && node.parent.operator === 50) { node = node.parent; } @@ -17735,8 +19094,11 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 219 + ? 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); @@ -17767,7 +19129,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220) { + if (node.initializer.kind !== 224) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17789,7 +19151,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212) { + if (node.kind === 216) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17809,7 +19171,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 ? breakTarget : continueTarget; + var flowLabel = node.kind === 215 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17866,7 +19228,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 === 254; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17927,11 +19289,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 !== 209) { + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 && node.operatorToken.kind === 57) { + if (node.kind === 192 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -17942,10 +19306,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171) { + else if (node.kind === 175) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192) { + if (e.kind === 196) { bindAssignmentTargetFlow(e.expression); } else { @@ -17953,15 +19317,18 @@ var ts; } } } - else if (node.kind === 172) { + else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253) { + if (p.kind === 257) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254) { + else if (p.kind === 258) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 259) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -18013,9 +19380,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 === 178) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18026,7 +19393,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173) { + if (node.expression.kind === 177) { bindAssignmentTargetFlow(node.expression); } } @@ -18036,9 +19403,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); @@ -18057,16 +19426,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 === 212 || node.parent.parent.kind === 213) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 179) { + while (expr.kind === 183) { expr = expr.expression; } - if (expr.kind === 180 || expr.kind === 181) { + if (expr.kind === 184 || expr.kind === 185) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18074,7 +19443,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173) { + if (node.expression.kind === 177) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18083,51 +19452,52 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193: - case 222: - case 225: - case 172: - case 160: - case 281: - case 265: - return 1; - case 223: - return 1 | 64; - case 269: + case 197: case 226: - case 224: + case 229: + case 176: + case 161: + case 286: + case 270: + return 1; + case 227: + return 1 | 64; + case 274: + case 230: + case 228: + case 170: return 1 | 32; - case 256: + case 261: 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 225: + 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 184: + case 185: return 1 | 4 | 32 | 8 | 16; - case 227: + case 231: return 4; - case 146: + case 147: return node.initializer ? 4 : 0; - case 252: - case 207: - case 208: - case 209: - case 228: + case 256: + case 211: + case 212: + case 213: + case 232: return 2; - case 200: + case 204: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18143,36 +19513,37 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 226: + case 230: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256: + case 261: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193: - case 222: + case 197: + case 226: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225: + case 229: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160: - case 172: - case 223: - case 265: - case 281: + case 161: + case 176: + case 227: + case 270: + case 286: 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 224: + case 152: + case 225: + case 184: + case 185: + case 274: + case 228: + case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18187,11 +19558,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 === 261 ? node : node.body; + if (body && (body.kind === 261 || body.kind === 231)) { 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 === 241 || stat.kind === 240) { return true; } } @@ -18263,20 +19634,15 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); if (inStrictMode) { 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 === 259 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 + var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18298,10 +19664,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226: + case 230: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256: + case 261: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -18391,8 +19757,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 226 && + if (blockScopeContainer.kind !== 261 && + blockScopeContainer.kind !== 230 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18435,7 +19801,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); @@ -18473,17 +19839,25 @@ var ts; function bindWorker(node) { switch (node.kind) { case 70: + if (node.isInJSDocNamespace) { + var parentNode = node.parent; + while (parentNode && parentNode.kind !== 284) { + 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 === 258)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173: + case 177: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188: + case 192: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -18506,111 +19880,132 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252: + case 256: return checkStrictModeCatchClause(node); - case 182: + case 186: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 187: + case 191: return checkStrictModePostfixUnaryExpression(node); - case 186: + case 190: return checkStrictModePrefixUnaryExpression(node); - case 213: + case 217: 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 223: + case 174: + if (node.dotDotDotToken && node.parent.kind === 172) { + emitFlags |= 32768; + } return bindVariableDeclarationOrBindingElement(node); + case 147: case 146: - case 145: - case 266: + case 271: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 280: + case 285: return bindJSDocProperty(node); - case 253: - case 254: + case 257: + case 258: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 255: + case 260: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 247: - emitFlags |= 16384; + case 259: + case 251: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 176 && + root.parent.kind === 192 && + 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 225: + 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 274: return bindFunctionOrConstructorType(node); - case 160: - case 281: - case 265: + case 161: + case 170: + case 286: + case 270: return bindAnonymousDeclaration(node, 2048, "__type"); - case 172: + case 176: return bindObjectLiteralExpression(node); - case 180: - case 181: + case 184: + case 185: return bindFunctionExpression(node); - case 175: + case 179: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 193: - case 222: + case 197: + case 226: inStrictMode = true; return bindClassLikeDeclaration(node); - case 223: + case 227: return bindBlockScopedDeclaration(node, 64, 792968); - case 279: - case 224: + case 284: + if (!node.fullName || node.fullName.kind === 70) { + return bindBlockScopedDeclaration(node, 524288, 793064); + } + break; + case 228: return bindBlockScopedDeclaration(node, 524288, 793064); - case 225: - 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); + return bindEnumDeclaration(node); + case 230: + return bindModuleDeclaration(node); + case 234: case 237: - return bindExportDeclaration(node); + case 239: + case 243: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 233: + return bindNamespaceExportDeclaration(node); case 236: + return bindImportClause(node); + case 241: + return bindExportDeclaration(node); + case 240: return bindExportAssignment(node); - case 256: + case 261: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200: + case 204: if (!ts.isFunctionLike(node.parent)) { return; } - case 227: + case 231: return updateStrictModeStatementList(node.statements); } } @@ -18619,7 +20014,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166) { + if (parameterName && parameterName.kind === 167) { seenThisKeyword = true; } bind(type); @@ -18638,7 +20033,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18648,17 +20043,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 !== 261) { 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_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_7.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -18697,11 +20092,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 221 || container.kind === 180) { + if (container.kind === 225 || container.kind === 184) { 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); @@ -18741,7 +20136,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 222) { + if (node.kind === 226) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -18859,15 +20254,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 !== 206) || + node.kind === 226 || + (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 || + (node.kind !== 205 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18881,54 +20276,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175: - return computeCallExpression(node, subtreeFlags); - case 176: - return computeNewExpression(node, subtreeFlags); - case 226: - return computeModuleDeclaration(node, subtreeFlags); case 179: - return computeParenthesizedExpression(node, subtreeFlags); - case 188: - return computeBinaryExpression(node, subtreeFlags); - case 203: - return computeExpressionStatement(node, subtreeFlags); - case 143: - return computeParameter(node, subtreeFlags); - case 181: - return computeArrowFunction(node, subtreeFlags); + return computeCallExpression(node, subtreeFlags); case 180: - return computeFunctionExpression(node, subtreeFlags); - case 221: - 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 computeClassDeclaration(node, subtreeFlags); - case 193: - return computeClassExpression(node, subtreeFlags); - case 251: - return computeHeritageClause(node, subtreeFlags); - case 195: - return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149: - return computeConstructor(node, subtreeFlags); - case 146: - return computePropertyDeclaration(node, subtreeFlags); - case 148: - return computeMethod(node, subtreeFlags); - case 150: - case 151: - return computeAccessor(node, subtreeFlags); + return computeNewExpression(node, subtreeFlags); case 230: + return computeModuleDeclaration(node, subtreeFlags); + case 183: + return computeParenthesizedExpression(node, subtreeFlags); + case 192: + return computeBinaryExpression(node, subtreeFlags); + case 207: + return computeExpressionStatement(node, subtreeFlags); + case 144: + return computeParameter(node, subtreeFlags); + case 185: + return computeArrowFunction(node, subtreeFlags); + case 184: + return computeFunctionExpression(node, subtreeFlags); + case 225: + return computeFunctionDeclaration(node, subtreeFlags); + case 223: + return computeVariableDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclarationList(node, subtreeFlags); + case 205: + return computeVariableStatement(node, subtreeFlags); + case 219: + return computeLabeledStatement(node, subtreeFlags); + case 226: + return computeClassDeclaration(node, subtreeFlags); + case 197: + return computeClassExpression(node, subtreeFlags); + case 255: + return computeHeritageClause(node, subtreeFlags); + case 256: + return computeCatchClause(node, subtreeFlags); + case 199: + return computeExpressionWithTypeArguments(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 234: return computeImportEquals(node, subtreeFlags); - case 173: + case 177: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -18942,19 +20339,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 177: + case 178: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -18966,27 +20363,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 === 176) { + transformFlags |= 48 | 3072 | 49152; + } + else if (operatorTokenKind === 57 && leftKind === 175) { + 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; @@ -18996,33 +20394,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 === 200 + || expressionKind === 182) { 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; @@ -19031,36 +20432,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; @@ -19070,15 +20470,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 |= 3072; + } + node.transformFlags = transformFlags | 536870912; + 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; @@ -19087,10 +20495,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 @@ -19099,13 +20507,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; @@ -19116,15 +20524,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; @@ -19134,27 +20542,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; @@ -19164,54 +20572,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 === 172) { + transformFlags |= 48 | 3072 | 67108864; + } + else if (nameKind === 173) { + transformFlags |= 3072 | 67108864; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19222,24 +20639,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; @@ -19247,15 +20661,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; @@ -19264,26 +20678,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 189: + transformFlags |= 192; break; case 113: case 111: @@ -19291,52 +20705,49 @@ var ts; case 116: case 123: case 75: - case 225: - case 255: - case 178: - case 196: - case 197: - case 129: + case 229: + case 260: + case 182: + case 200: + case 201: + case 130: transformFlags |= 3; break; - case 242: - case 243: - case 244: - case 10: - case 245: case 246: case 247: case 248: + case 10: + case 249: + case 250: + case 251: + case 252: transformFlags |= 12; break; - case 83: - transformFlags |= 768 | 3; - break; - case 78: + case 213: + transformFlags |= 48; case 12: case 13: case 14: case 15: - case 190: - case 177: - case 254: - case 209: - transformFlags |= 768; + case 194: + case 181: + case 258: + case 114: + transformFlags |= 3072; break; - case 191: - transformFlags |= 768 | 16777216; + case 195: + 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: @@ -19350,73 +20761,142 @@ var ts; case 163: case 164: case 165: - case 223: - case 224: case 166: + case 227: + case 228: case 167: + case 168: + case 169: + case 170: + case 171: 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 196: + case 259: + transformFlags |= 8388608; break; + case 174: + 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; + transformFlags |= 262144; break; case 172: - excludeFlags = 539110741; - if (subtreeFlags & 2097152) { - transformFlags |= 768; + case 173: + if (subtreeFlags & 8388608) { + transformFlags |= 48 | 67108864; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + else { + transformFlags |= 3072 | 67108864; } break; - case 171: + case 145: + transformFlags |= 3 | 65536; + break; case 176: - excludeFlags = 537922901; + excludeFlags = 554784085; + if (subtreeFlags & 16777216) { + transformFlags |= 3072; + } if (subtreeFlags & 1048576) { - transformFlags |= 768; + transformFlags |= 262144; + } + if (subtreeFlags & 8388608) { + transformFlags |= 48; } break; - case 205: - case 206: - case 207: - case 208: - if (subtreeFlags & 4194304) { - transformFlags |= 768; + case 175: + case 180: + excludeFlags = 545281365; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } break; - case 256: - if (subtreeFlags & 65536) { - transformFlags |= 768; - } - break; - case 212: + case 209: case 210: case 211: - transformFlags |= 33554432; + case 212: + if (subtreeFlags & 33554432) { + transformFlags |= 3072; + } + break; + case 261: + if (subtreeFlags & 524288) { + transformFlags |= 3072; + } + break; + case 216: + case 214: + case 215: + transformFlags |= 268435456; break; } node.transformFlags = transformFlags | 536870912; return transformFlags & ~excludeFlags; } + function getTransformFlagsSubtreeExclusions(kind) { + if (kind >= 156 && kind <= 171) { + return -3; + } + switch (kind) { + case 179: + case 180: + case 175: + return 545281365; + case 230: + return 839734613; + case 144: + return 604001621; + case 185: + return 979719509; + case 184: + case 225: + return 980243797; + case 224: + return 604001621; + case 226: + case 197: + return 559895893; + case 150: + return 975983957; + case 149: + case 151: + 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 155: + case 227: + case 228: + return -3; + case 176: + return 554784085; + default: + return 536892757; + } + } + ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; })(ts || (ts = {})); var ts; (function (ts) { @@ -19504,7 +20984,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(); @@ -19518,9 +21001,9 @@ var ts; var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 33554432, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 2097152, "undefined"); var nullType = createIntrinsicType(4096, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 33554432, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 2097152, "null"); var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var trueType = createIntrinsicType(128, "true"); @@ -19530,11 +21013,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 |= 134217728; + 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); @@ -19596,66 +21083,6 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; - TypeFacts[TypeFacts["All"] = 8388607] = "All"; - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -19682,6 +21109,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", @@ -19698,17 +21127,25 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); 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; @@ -19789,7 +21226,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { + (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -19845,7 +21282,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; } @@ -19882,8 +21319,11 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } + function getObjectFlags(type) { + return type.flags & 32768 ? type.objectFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 256 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -19920,36 +21360,39 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } + if (isUsedInFunctionOrNonStaticProperty(usage)) { + return true; + } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 219 || + return declaration.kind !== 223 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } - return isUsedInFunctionOrNonStaticProperty(declaration, usage); + var container = ts.getEnclosingBlockScopeContainer(declaration); + return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201: - case 207: - case 209: + case 205: + case 211: + case 213: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 208: - case 209: + case 212: + case 213: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); + function isUsedInFunctionOrNonStaticProperty(usage, container) { var current = usage; while (current) { if (current === container) { @@ -19959,7 +21402,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) { @@ -19982,18 +21425,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 !== 278) { 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) { @@ -20005,13 +21448,13 @@ var ts; } } switch (location.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226: + case 230: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 || ts.isAmbientModule(location)) { + if (location.kind === 261 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20021,7 +21464,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 239)) { + ts.getDeclarationOfKind(moduleExports[name], 243)) { break; } } @@ -20029,13 +21472,13 @@ var ts; break loop; } break; - case 225: + case 229: 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) { @@ -20045,9 +21488,9 @@ var ts; } } break; - case 222: - case 193: - case 223: + case 226: + case 197: + case 227: 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); @@ -20055,7 +21498,7 @@ var ts; } break loop; } - if (location.kind === 193 && meaning & 32) { + if (location.kind === 197 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20063,28 +21506,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 === 227) { 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 225: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180: + case 184: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20097,8 +21540,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)) { @@ -20140,7 +21583,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 === 233) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20187,9 +21630,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 173: + case 177: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195: + case 199: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20210,7 +21653,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, 223), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20227,10 +21670,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230) { + if (node.kind === 234) { return node; } - while (node && node.kind !== 231) { + while (node && node.kind !== 235) { node = node.parent; } return node; @@ -20240,7 +21683,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 === 245) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20301,28 +21744,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_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_13.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_19.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_19.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_13.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_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); + error(name_19, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_19)); } return symbol; } @@ -20344,19 +21787,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230: + case 234: return getTargetOfImportEqualsDeclaration(node); - case 232: - return getTargetOfImportClause(node); - case 233: - return getTargetOfNamespaceImport(node); - case 235: - return getTargetOfImportSpecifier(node); - case 239: - return getTargetOfExportSpecifier(node); case 236: + return getTargetOfImportClause(node); + case 237: + return getTargetOfNamespaceImport(node); + case 239: + return getTargetOfImportSpecifier(node); + case 243: + return getTargetOfExportSpecifier(node); + case 240: return getTargetOfExportAssignment(node); - case 229: + case 233: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20400,10 +21843,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236) { + if (node.kind === 240) { checkExpressionCached(node.expression); } - else if (node.kind === 239) { + else if (node.kind === 243) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20415,11 +21858,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 === 234); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20438,9 +21881,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 === 177) { + 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; @@ -20465,27 +21908,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); @@ -20501,14 +21945,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; @@ -20623,7 +22083,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; } } @@ -20645,8 +22105,9 @@ var ts; type.intrinsicName = "boolean"; return type; } - function createObjectType(kind, symbol) { - var type = createType(kind); + function createObjectType(objectFlags, symbol) { + var type = createType(32768); + type.objectFlags = objectFlags; type.symbol = symbol; return type; } @@ -20670,7 +22131,7 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; @@ -20682,7 +22143,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - return setObjectTypeMembers(createObjectType(2097152, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -20693,11 +22154,11 @@ var ts; } } switch (location_1.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226: + case 230: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -20730,7 +22191,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -20761,7 +22222,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, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -20775,10 +22236,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; @@ -20834,7 +22295,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -20868,11 +22329,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 === 177 || + entityName.parent.kind === 234) { meaning = 1920; } else { @@ -20964,10 +22425,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 === 228) { return getSymbolOfNode(node); } } @@ -20975,7 +22436,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 && + node.parent.kind === 231 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -20989,10 +22450,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193: + case 197: return "(Anonymous class)"; - case 180: - case 181: + case 184: + case 185: return "(Anonymous function)"; } } @@ -21044,9 +22505,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_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21087,7 +22548,7 @@ var ts; } writer.writeKeyword("this"); } - else if (type.flags & 131072) { + else if (getObjectFlags(type) & 4) { writeTypeReference(type, nextFlags); } else if (type.flags & 256) { @@ -21095,23 +22556,34 @@ var ts; writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } - else if (type.flags & (32768 | 65536 | 16 | 16384)) { + else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && ((type.flags & 2097152 && !type.target) || type.flags & 1572864) && type.aliasSymbol && + else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } - else if (type.flags & 1572864) { + else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); } - else if (type.flags & 2097152) { + else if (getObjectFlags(type) & (16 | 32)) { writeAnonymousType(type, nextFlags); } 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); @@ -21156,7 +22628,7 @@ var ts; writePunctuation(writer, 20); writePunctuation(writer, 21); } - else if (type.target.flags & 262144) { + else if (type.target.objectFlags & 8) { writePunctuation(writer, 20); writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); writePunctuation(writer, 21); @@ -21168,12 +22640,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21186,7 +22658,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 18); } - if (type.flags & 524288) { + if (type.flags & 65536) { writeTypeList(formatUnionTypes(type.types), 48); } else { @@ -21232,7 +22704,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 === 261 || declaration.parent.kind === 231; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21248,7 +22720,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } writePunctuation(writer, 20); @@ -21266,7 +22738,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -21286,6 +22758,12 @@ var ts; return false; } function writeLiteralType(type, flags) { + if (type.objectFlags & 32) { + if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { + writeMappedType(type); + return; + } + } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { @@ -21322,6 +22800,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); @@ -21334,8 +22818,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); @@ -21358,9 +22842,32 @@ var ts; writer.writeLine(); } } + } + function writeMappedType(type) { + writePunctuation(writer, 16); + writer.writeLine(); + writer.increaseIndent(); + if (type.declaration.readonlyToken) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); + writeSpace(writer); + writeKeyword(writer, 91); + writeSpace(writer); + writeType(getConstraintTypeFromMappedType(type), 0); + writePunctuation(writer, 21); + if (type.declaration.questionToken) { + writePunctuation(writer, 54); + } + writePunctuation(writer, 55); + writeSpace(writer); + writeType(getTemplateTypeFromMappedType(type), 0); + writePunctuation(writer, 24); + writer.writeLine(); writer.decreaseIndent(); writePunctuation(writer, 17); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -21398,12 +22905,12 @@ var ts; buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 172) { 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 === 173) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -21417,7 +22924,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170); + ts.Debug.assert(bindingElement.kind === 174); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55); @@ -21545,63 +23052,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170: + case 174: return isDeclarationVisible(node.parent.parent); - case 219: + case 223: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 226: - case 222: - case 223: - case 224: - case 221: - case 225: case 230: + case 226: + case 227: + case 228: + case 225: + case 229: + case 234: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 234 && parent_8.kind !== 261 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_10); - case 146: - case 145: - case 150: - case 151: - case 148: + return isDeclarationVisible(parent_8); 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 231: 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 237: + case 239: + return false; + case 143: + case 261: + case 233: + return true; + case 240: return false; default: return false; @@ -21610,10 +23117,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236) { + if (node.parent && node.parent.kind === 240) { 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 === 243) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -21675,7 +23182,6 @@ var ts; return getSymbolLinks(target).declaredType; } if (propertyName === 1) { - ts.Debug.assert(!!(target.flags & 32768)); return target.resolvedBaseConstructorType; } if (propertyName === 3) { @@ -21692,12 +23198,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219: - case 220: - case 235: - case 234: - case 233: - case 232: + case 223: + case 224: + case 239: + case 238: + case 237: + case 236: node = node.parent; break; default: @@ -21723,22 +23229,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; @@ -21753,26 +23267,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 === 172) { + 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 !== 198 && !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_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) @@ -21787,9 +23320,6 @@ var ts; return unknownType; } } - else { - type = createArrayType(elementType); - } } if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) { type = getTypeWithFacts(type, 131072); @@ -21809,15 +23339,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 === 223 && + declaration.parent.kind === 224 && + declaration.parent.parent.kind === 205) { 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; @@ -21831,22 +23361,22 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 && expr.elements.length === 0; + return expr.kind === 175 && 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 === 212) { return stringType; } - if (declaration.parent.parent.kind === 209) { + if (declaration.parent.parent.kind === 213) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -21855,7 +23385,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 === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -21864,10 +23394,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); @@ -21893,7 +23423,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 254) { + if (declaration.kind === 258) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -21918,11 +23448,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); @@ -21934,7 +23464,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= 512; } return result; } @@ -21953,7 +23483,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 + return pattern.kind === 172 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -21963,7 +23493,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 253) { + if (declaration.kind === 257) { return type; } return getWidenedType(type); @@ -21978,7 +23508,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) { @@ -21988,28 +23518,28 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 252) { + if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 236) { + if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 285 && 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 === 192 || + declaration.kind === 177 && declaration.parent.kind === 192) { + 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 === 192 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22035,7 +23565,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150) { + if (accessor.kind === 151) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22055,9 +23585,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; @@ -22097,7 +23627,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)); } } @@ -22108,11 +23638,11 @@ 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 { - var type = createObjectType(2097152, symbol); + var type = createObjectType(16, symbol); links.type = strictNullChecks && symbol.flags & 536870912 ? includeFalsyTypes(type, 2048) : type; } @@ -22165,7 +23695,7 @@ var ts; return unknownType; } function getTargetType(type) { - return type.flags & 131072 ? type.target : type; + return getObjectFlags(type) & 4 ? type.target : type; } function hasBaseType(type, checkBase) { return check(type); @@ -22193,9 +23723,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 === 226 || node.kind === 197 || + node.kind === 225 || node.kind === 184 || + node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22204,15 +23734,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, 227); 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 === 227 || node.kind === 226 || + node.kind === 197 || node.kind === 228) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22225,7 +23755,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 2588672 && getSignaturesOfType(type, 1).length > 0; + return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -22237,7 +23767,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; @@ -22252,7 +23782,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 2588672) { + if (baseConstructorType.flags & 32768) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -22269,7 +23799,7 @@ var ts; } function getBaseTypes(type) { if (!type.resolvedBaseTypes) { - if (type.flags & 262144) { + if (type.objectFlags & 8) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } else if (type.symbol.flags & (32 | 64)) { @@ -22289,7 +23819,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 2588672)) { + if (!(baseConstructorType.flags & 32768)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -22310,7 +23840,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getTargetType(baseType).flags & (32768 | 65536))) { + if (!(getObjectFlags(getTargetType(baseType)) & 3)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -22338,12 +23868,12 @@ 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 === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (32768 | 65536)) { + if (getObjectFlags(getTargetType(baseType)) & 3) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -22367,7 +23897,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 === 227) { if (declaration.flags & 64) { return false; } @@ -22390,12 +23920,12 @@ var ts; function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var kind = symbol.flags & 32 ? 32768 : 65536; + var kind = symbol.flags & 32 ? 1 : 2; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters || kind === 32768 || !isIndependentInterface(symbol)) { - type.flags |= 131072; + if (outerTypeParameters || localTypeParameters || kind === 1 || !isIndependentInterface(symbol)) { + type.objectFlags |= 4; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -22417,8 +23947,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279); + var declaration = ts.getDeclarationOfKind(symbol, 284); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22429,14 +23958,15 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224); - type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); + declaration = ts.getDeclarationOfKind(symbol, 228); + type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { - links.typeParameters = typeParameters; + var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { + links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(links.typeParameters)] = type; + links.instantiations[getTypeListId(typeParameters)] = type; } } else { @@ -22453,14 +23983,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 190 && 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 === 229) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22488,7 +24018,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 === 229) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22503,7 +24033,7 @@ var ts; } enumType.memberTypes = memberTypes; if (memberTypeList.length > 1) { - enumType.flags |= 524288; + enumType.flags |= 65536; enumType.types = memberTypeList; unionTypes[getTypeListId(memberTypeList)] = enumType; } @@ -22515,7 +24045,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - links.declaredType = enumType.flags & 524288 ? + links.declaredType = enumType.flags & 65536 ? enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : enumType; } @@ -22526,7 +24056,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; @@ -22576,19 +24106,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 171: return true; - case 161: + case 162: return isIndependentType(node.elementType); - case 156: + case 157: return isIndependentTypeReference(node); } return false; @@ -22597,7 +24127,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++) { @@ -22613,12 +24143,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); } } @@ -22661,7 +24191,7 @@ var ts; return type; } function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 131072) { + if (getObjectFlags(type) & 4) { return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); } return type; @@ -22684,8 +24214,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); } @@ -22705,7 +24235,7 @@ var ts; numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -22740,14 +24270,14 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNodeNoAlias); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { 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); @@ -22832,7 +24362,7 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1); var stringIndexInfo = getUnionIndexInfo(type.types, 0); var numberIndexInfo = getUnionIndexInfo(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); @@ -22840,6 +24370,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; @@ -22852,17 +24385,17 @@ var ts; stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { 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); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { var members = symbol.members; @@ -22870,7 +24403,7 @@ var ts; var constructSignatures = getSignaturesOfSymbol(members["__new"]); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { var members = emptySymbols; @@ -22885,46 +24418,106 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 2588672) { + if (baseConstructorType.flags & 32768) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } } } + function resolveMappedTypeMembers(type) { + var members = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + var typeParameter = getTypeParameterFromMappedType(type); + var constraintType = getConstraintTypeFromMappedType(type); + var templateType = getTemplateTypeFromMappedType(type); + var isReadonly = !!type.declaration.readonlyToken; + var isOptional = !!type.declaration.questionToken; + var keyType = constraintType.flags & 16384 ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 262144 ? getIndexType(getApparentType(keyType.type)) : keyType; + forEachType(iterationType, function (t) { + var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; + var propType = instantiateType(templateType, templateMapper); + if (t.flags & (32 | 64 | 256)) { + var propName = t.text; + var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + prop.type = addOptionality(propType, isOptional); + prop.isReadonly = isReadonly; + members[propName] = prop; + } + else if (t.flags & 2) { + stringIndexInfo = createIndexInfo(propType, isReadonly); + } + else if (t.flags & 4) { + numberIndexInfo = createIndexInfo(propType, isReadonly); + } + }); + if (stringIndexInfo && numberIndexInfo && isTypeIdenticalTo(stringIndexInfo.type, numberIndexInfo.type)) { + numberIndexInfo = undefined; + } + setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } + function getTypeParameterFromMappedType(type) { + return type.typeParameter || + (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter))); + } + function getConstraintTypeFromMappedType(type) { + return type.constraintType || + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + } + function getTemplateTypeFromMappedType(type) { + return type.templateType || + (type.templateType = type.declaration.type ? + instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + unknownType); + } + function isGenericMappedType(type) { + if (getObjectFlags(type) & 32) { + var constraintType = getConstraintTypeFromMappedType(type); + return !!(constraintType.flags & (16384 | 262144)); + } + return false; + } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072) { - resolveTypeReferenceMembers(type); + if (type.flags & 32768) { + if (type.objectFlags & 4) { + resolveTypeReferenceMembers(type); + } + else if (type.objectFlags & 3) { + resolveClassOrInterfaceMembers(type); + } + else if (type.objectFlags & 16) { + resolveAnonymousTypeMembers(type); + } + else if (type.objectFlags & 32) { + resolveMappedTypeMembers(type); + } } - else if (type.flags & (32768 | 65536)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 2097152) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 524288) { + else if (type.flags & 65536) { resolveUnionTypeMembers(type); } - else if (type.flags & 1048576) { + else if (type.flags & 131072) { resolveIntersectionTypeMembers(type); } } return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { return resolveStructuredTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -22939,7 +24532,7 @@ var ts; var prop = _c[_b]; getUnionOrIntersectionProperty(type, prop.name); } - if (type.flags & 524288) { + if (type.flags & 65536) { break; } } @@ -22958,7 +24551,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 1572864 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { @@ -22971,27 +24566,18 @@ 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; var props; - var commonFlags = (containingType.flags & 1048576) ? 536870912 : 0; + var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; var isReadonly = false; var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { @@ -23011,7 +24597,7 @@ var ts; isReadonly = true; } } - else if (containingType.flags & 524288) { + else if (containingType.flags & 65536) { isPartial = true; } } @@ -23046,7 +24632,7 @@ var ts; result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; - result.type = containingType.flags & 524288 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { @@ -23066,7 +24652,7 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -23080,13 +24666,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 1572864) { + if (type.flags & 196608) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 4161536) { + if (type.flags & 229376) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -23096,7 +24682,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 4161536) { + if (type.flags & 229376) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -23127,7 +24713,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); @@ -23155,8 +24741,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 === 273) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -23165,11 +24751,18 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268; + return paramTag.typeExpression.type.kind === 273; } } } } + 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; @@ -23223,7 +24816,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167) { + if (param.type && param.type.kind === 171) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23235,10 +24828,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); @@ -23250,14 +24843,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); @@ -23274,14 +24867,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)) { @@ -23295,20 +24888,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 225: 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 184: + case 185: + case 274: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23369,13 +24962,18 @@ var ts; function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 131072 && type.target === globalArrayType) { + if (getObjectFlags(type) & 4 && type.target === globalArrayType) { return type.typeArguments[0]; } } 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) { @@ -23388,8 +24986,8 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; - var type = createObjectType(2097152); + var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -23402,7 +25000,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++) { @@ -23429,7 +25027,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; @@ -23462,7 +25060,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 = ""; @@ -23495,22 +25093,23 @@ var ts; result |= type.flags; } } - return result & 234881024; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var propagatedFlags = typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; - var flags = 131072 | propagatedFlags; - type = target.instantiations[id] = createObjectType(flags, target.symbol); + type = target.instantiations[id] = createObjectType(4, target.symbol); + type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; } return type; } function cloneTypeReference(source) { - var type = createObjectType(source.flags, source.symbol); + var type = createType(source.flags); + type.symbol = source.symbol; + type.objectFlags = source.objectFlags; type.target = source.target; type.typeArguments = source.typeArguments; return type; @@ -23526,7 +25125,7 @@ var ts; error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias))); + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -23534,18 +25133,23 @@ var ts; } return type; } - function getTypeFromTypeAliasReference(node, symbol) { + function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); return unknownType; } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + return getTypeAliasInstantiation(symbol, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); @@ -23562,11 +25166,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156: + case 157: return node.typeName; - case 267: + case 272: return node.name; - case 195: + case 199: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23590,7 +25194,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 267) { + if (symbol.flags & 107455 && node.kind === 272) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -23600,13 +25204,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267) { + if (node.kind === 272) { 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 @@ -23635,9 +25239,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 227: + case 229: return declaration; } } @@ -23646,7 +25250,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 2588672)) { + if (!(type.flags & 32768)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -23709,7 +25313,7 @@ var ts; property.type = typeParameter; properties.push(property); } - var type = createObjectType(262144 | 131072); + var type = createObjectType(8 | 4); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -23736,7 +25340,7 @@ var ts; function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNodeNoAlias)); + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); } return links.resolvedType; } @@ -23764,7 +25368,7 @@ var ts; } function addTypeToUnion(typeSet, type) { var flags = type.flags; - if (flags & 524288) { + if (flags & 65536) { addTypesToUnion(typeSet, type.types); } else if (flags & 1) { @@ -23775,7 +25379,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096) typeSet.containsNull = true; - if (!(flags & 33554432)) + if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192)) { @@ -23788,7 +25392,8 @@ var ts; var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & 2097152 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + if (!(flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } } @@ -23850,7 +25455,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 && types.containsString || t.flags & 64 && types.containsNumber || - t.flags & 96 && t.flags & 16777216 && containsType(types, t.regularType); + t.flags & 96 && t.flags & 1048576 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -23892,22 +25497,22 @@ var ts; var type = unionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createObjectType(524288 | propagatedFlags); + type = unionTypes[id] = createType(65536 | propagatedFlags); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), false, aliasSymbol, aliasTypeArguments); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), false, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } function addTypeToIntersection(typeSet, type) { - if (type.flags & 1048576) { + if (type.flags & 131072) { addTypesToIntersection(typeSet, type.types); } else if (type.flags & 1) { @@ -23927,6 +25532,17 @@ var ts; if (types.length === 0) { return emptyObjectType; } + 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_2(i); + if (typeof state_2 === "object") + return state_2.value; + } var typeSet = []; addTypesToIntersection(typeSet, types); if (typeSet.containsAny) { @@ -23939,39 +25555,248 @@ var ts; var type = intersectionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createObjectType(1048576 | propagatedFlags); + type = intersectionTypes[id] = createType(131072 | propagatedFlags); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), aliasSymbol, aliasTypeArguments); + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return getDeclarationModifierFlagsFromSymbol(prop) & 24 || 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) { - var type = createObjectType(2097152, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = getIndexType(getTypeFromTypeNode(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 === 178 ? 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 === 178 ? 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 (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + 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(getTypeFromTypeNode(node.objectType), getTypeFromTypeNode(node.indexType), node); + } + return links.resolvedType; + } + function getTypeFromMappedTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = createObjectType(32, node.symbol); + type.declaration = node; + type.aliasSymbol = getAliasSymbolForTypeNode(node); + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); links.resolvedType = type; } return links.resolvedType; } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + links.resolvedType = type; + } + } + return links.resolvedType; + } + function getAliasSymbolForTypeNode(node) { + return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + } + function getAliasTypeArgumentsForTypeNode(node) { + var symbol = getAliasSymbolForTypeNode(node); + return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; + } + 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 & 16777216)) { + if (type.flags & 96 && !(type.flags & 1048576)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 16777216, type.text); + var freshType = createLiteralType(type.flags | 1048576, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -23980,7 +25805,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 16777216 ? type.regularType : type; + return type.flags & 96 && type.flags & 1048576 ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; @@ -24004,7 +25829,7 @@ var ts; function getTypeFromJSDocTupleType(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var types = ts.map(node.types, getTypeFromTypeNodeNoAlias); + var types = ts.map(node.types, getTypeFromTypeNode); links.resolvedType = createTupleType(types); } return links.resolvedType; @@ -24012,9 +25837,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 === 227)) { 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; } } @@ -24028,85 +25853,88 @@ var ts; } return links.resolvedType; } - function getTypeFromTypeNodeNoAlias(type) { - return getTypeFromTypeNode(type, undefined, undefined); - } - function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 258: - case 259: + case 263: + case 264: 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 288: return nullType; - case 284: + case 289: return undefinedType; - case 285: + case 290: return neverType; - case 166: + case 167: case 98: return getTypeFromThisTypeNode(node); - case 167: + case 171: return getTypeFromLiteralTypeNode(node); - case 282: + case 287: 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 272: + return getTypeFromTypeReference(node); + case 156: + return booleanType; + case 199: + return getTypeFromTypeReference(node); case 160: - case 281: + return getTypeFromTypeQueryNode(node); + case 162: + case 265: + return getTypeFromArrayTypeNode(node); + case 163: + return getTypeFromTupleTypeNode(node); + case 164: + case 266: + return getTypeFromUnionTypeNode(node); + case 165: + return getTypeFromIntersectionTypeNode(node); + case 166: + case 268: case 269: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 276: + case 277: + case 273: + return getTypeFromTypeNode(node.type); + case 270: + return getTypeFromTypeNode(node.literal); + case 158: + case 159: + case 161: + case 286: + case 274: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 168: + return getTypeFromTypeOperatorNode(node); + case 169: + return getTypeFromIndexedAccessTypeNode(node); + case 170: + return getTypeFromMappedTypeNode(node); case 70: - case 140: + case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262: + case 267: return getTypeFromJSDocTupleType(node); - case 270: + case 275: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24123,6 +25951,16 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } + function instantiateCached(type, mapper, instantiator) { + var instantiations = mapper.instantiations || (mapper.instantiations = []); + return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -24145,7 +25983,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) { @@ -24235,45 +26072,46 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - var result = createObjectType(2097152 | 4194304, type.symbol); - result.target = type; - result.mapper = mapper; + var result = createObjectType(16 | 64, type.symbol); + result.target = type.objectFlags & 64 ? type.target : type; + result.mapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; - mapper.instantiations[type.id] = result; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + return result; + } + function instantiateMappedType(type, mapper) { + var result = createObjectType(32 | 64, type.symbol); + result.declaration = type.declaration; + result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + result.aliasSymbol = type.aliasSymbol; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); 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 225: 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 184: + case 185: + case 226: + case 197: + case 227: + case 228: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24283,69 +26121,97 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223) { + if (ts.isClassLike(node) || node.kind === 227) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226: - case 256: + case 230: + case 261: return false; } node = node.parent; } return false; } + function isTopLevelTypeAlias(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var parentKind = symbol.declarations[0].parent.kind; + return parentKind === 261 || parentKind === 231; + } + return false; + } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.flags & 16384) { - return mapper(type); + if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { + if (type.aliasTypeArguments) { + return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + return type; } - if (type.flags & 2097152) { + return instantiateTypeNoAlias(type, mapper); + } + return type; + } + function instantiateTypeNoAlias(type, mapper) { + if (type.flags & 16384) { + return mapper(type); + } + if (type.flags & 32768) { + if (type.objectFlags & 16) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && - (type.flags & 4194304 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateAnonymousType(type, mapper) : type; + (type.objectFlags & 64 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? + instantiateCached(type, mapper, instantiateAnonymousType) : type; } - if (type.flags & 131072) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + if (type.objectFlags & 32) { + return instantiateCached(type, mapper, instantiateMappedType); } - if (type.flags & 524288 && !(type.flags & 8190)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), false, type.aliasSymbol, mapper.targetTypes); - } - if (type.flags & 1048576) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + if (type.objectFlags & 4) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } + if (type.flags & 65536 && !(type.flags & 8190)) { + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 131072) { + 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; } function instantiateIndexInfo(info, mapper) { 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 184: + case 185: return isContextSensitiveFunctionLikeDeclaration(node); - case 172: + case 176: return ts.forEach(node.properties, isContextSensitive); - case 171: + case 175: return ts.forEach(node.elements, isContextSensitive); - case 189: + case 193: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188: + case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253: + case 257: return isContextSensitive(node.initializer); + case 149: case 148: - case 147: return isContextSensitiveFunctionLikeDeclaration(node); - case 179: + case 183: return isContextSensitive(node.expression); } return false; @@ -24357,7 +26223,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 181) { + if (node.kind === 185) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -24367,10 +26233,10 @@ var ts; return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(2097152, type.symbol); + var result = createObjectType(16, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -24549,7 +26415,7 @@ var ts; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || - (source.flags & 524288) !== (target.flags & 524288)) { + (source.flags & 65536) !== (target.flags & 65536)) { return enumRelation[id] = false; } var targetEnumType = getTypeOfSymbol(target.symbol); @@ -24606,23 +26472,23 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 16777216) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 16777216) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 2588672 && target.flags & 2588672) { + if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related === 1; } } - if (source.flags & 4177920 || target.flags & 4177920) { + if (source.flags & 507904 || target.flags & 507904) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -24659,9 +26525,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); } @@ -24677,10 +26549,10 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 && source.flags & 16777216) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 16777216) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target) @@ -24690,19 +26562,24 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (source.flags & 8388608 && source.flags & 16777216) { + if (source.flags & 262144) { + if (maybeTypeOfKind(target, 2) && maybeTypeOfKind(target, 4)) { + return -1; + } + } + if (getObjectFlags(source) & 128 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); } return 0; } - if (target.flags & 1572864) { + if (target.flags & 196608) { source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 524288) { + if (source.flags & 65536) { if (relation === comparableRelation) { result = someTypeRelatedToType(source, target, reportErrors && !(source.flags & 8190)); } @@ -24713,20 +26590,38 @@ var ts; return result; } } - else if (target.flags & 1048576) { - result = typeRelatedToEachType(source, target, reportErrors); - if (result) { + else if (target.flags & 65536) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { return result; } } - else { - if (source.flags & 1048576) { - if (result = someTypeRelatedToType(source, target, false)) { + else if (target.flags & 131072) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072) { + if (result = someTypeRelatedToType(source, target, false)) { + return result; + } + } + if (target.flags & 16384) { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { return result; } } - if (target.flags & 524288) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { + } + else if (target.flags & 262144) { + if (source.flags & 262144) { + if (result = isRelatedTo(target.type, source.type, false)) { + return result; + } + } + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { return result; } } @@ -24744,25 +26639,35 @@ var ts; } } else { - if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } - var apparentSource = getApparentType(source); - if (apparentSource.flags & (2588672 | 1048576) && target.flags & 2588672) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; + if (isGenericMappedType(target)) { + if (isGenericMappedType(source)) { + if ((result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) && + (result = isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors))) { + return result; + } + } + } + else { + var apparentSource = getApparentType(source); + if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } if (reportErrors) { - if (source.flags & 2588672 && target.flags & 8190) { + if (source.flags & 32768 && target.flags & 8190) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 2588672 && globalObjectType === source) { + else if (source.symbol && source.flags & 32768 && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } reportRelationError(headMessage, source, target); @@ -24771,16 +26676,16 @@ var ts; } function isIdenticalTo(source, target) { var result; - if (source.flags & 2588672 && target.flags & 2588672) { - if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + if (source.flags & 32768 && target.flags & 32768) { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } return objectTypeRelatedTo(source, source, target, false); } - if (source.flags & 524288 && target.flags & 524288 || - source.flags & 1048576 && target.flags & 1048576) { + if (source.flags & 65536 && target.flags & 65536 || + source.flags & 131072 && target.flags & 131072) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -24790,7 +26695,7 @@ var ts; return 0; } function isKnownProperty(type, name) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || @@ -24799,7 +26704,7 @@ var ts; return true; } } - else if (type.flags & 1572864) { + else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name)) { @@ -24817,8 +26722,7 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (maybeTypeOfKind(target, 2588672) && - (!(target.flags & 2588672) || !target.isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -24848,7 +26752,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 524288 && containsType(targetTypes, source)) { + if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } var len = targetTypes.length; @@ -24875,7 +26779,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 524288 && containsType(sourceTypes, target)) { + if (source.flags & 65536 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; @@ -24995,9 +26899,9 @@ var ts; } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 8388608); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); + 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) { @@ -25049,7 +26953,7 @@ var ts; return 0; } result &= related; - if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -25061,7 +26965,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 2588672 && target.flags & 2588672)) { + if (!(source.flags & 32768 && target.flags & 32768)) { return 0; } var sourceProperties = getPropertiesOfObjectType(source); @@ -25233,7 +27137,7 @@ var ts; } } function isAbstractConstructorType(type) { - if (type.flags & 2097152) { + if (getObjectFlags(type) & 16) { var symbol = type.symbol; if (symbol && symbol.flags & 32) { var declaration = getClassLikeDeclarationOfSymbol(symbol); @@ -25245,12 +27149,12 @@ var ts; return false; } function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (131072 | 4194304) && depth >= 5) { + if (getObjectFlags(type) & (4 | 64) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (131072 | 4194304) && t.symbol === symbol) { + if (getObjectFlags(t) & (4 | 64) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -25408,10 +27312,10 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isArrayType(type) { - return type.flags & 131072 && type.target === globalArrayType; + return getObjectFlags(type) & 4 && type.target === globalArrayType; } function isArrayLikeType(type) { - return type.flags & 131072 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + return getObjectFlags(type) & 4 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || !(type.flags & 6144) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { @@ -25422,7 +27326,7 @@ var ts; } function isLiteralType(type) { return type.flags & 8 ? true : - type.flags & 524288 ? type.flags & 16 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + type.flags & 65536 ? type.flags & 16 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { @@ -25430,19 +27334,19 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 32 && type.flags & 16777216 ? stringType : - type.flags & 64 && type.flags & 16777216 ? 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 & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { - return !!(type.flags & 131072 && type.target.flags & 262144); + return !!(getObjectFlags(type) & 4 && type.target.objectFlags & 8); } function getFalsyFlagsOfTypes(types) { var result = 0; @@ -25453,7 +27357,7 @@ var ts; return result; } function getFalsyFlags(type) { - return type.flags & 524288 ? getFalsyFlagsOfTypes(type.types) : + return type.flags & 65536 ? getFalsyFlagsOfTypes(type.types) : type.flags & 32 ? type.text === "" ? 32 : 0 : type.flags & 64 ? type.text === "0" ? 64 : 0 : type.flags & 128 ? type === falseType ? 128 : 0 : @@ -25514,7 +27418,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(type.flags & 8388608 && type.flags & 16777216)) { + if (!(getObjectFlags(type) & 128 && type.flags & 1048576)) { return type; } var regularType = type.regularType; @@ -25524,7 +27428,8 @@ 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 & ~16777216; + regularNew.flags = resolved.flags & ~1048576; + regularNew.objectFlags |= 128; type.regularType = regularNew; return regularNew; } @@ -25541,14 +27446,14 @@ var ts; return type.flags & 6144 ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 100663296) { + if (type.flags & 6291456) { if (type.flags & 6144) { return anyType; } - if (type.flags & 8388608) { + if (getObjectFlags(type) & 128) { return getWidenedTypeOfObjectLiteral(type); } - if (type.flags & 524288) { + if (type.flags & 65536) { return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { @@ -25559,7 +27464,7 @@ var ts; } function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 524288) { + if (type.flags & 65536) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (reportWideningErrorsInType(t)) { @@ -25575,11 +27480,11 @@ var ts; } } } - if (type.flags & 8388608) { + if (getObjectFlags(type) & 128) { for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 33554432) { + 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))); } @@ -25593,25 +27498,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 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221: + case 225: + case 149: case 148: - case 147: - case 150: case 151: - case 180: - case 181: + case 152: + case 184: + case 185: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25624,7 +27529,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 33554432) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -25668,10 +27573,12 @@ var ts; }; } function couldContainTypeParameters(type) { + var objectFlags = getObjectFlags(type); return !!(type.flags & 16384 || - type.flags & 131072 && ts.forEach(type.typeArguments, couldContainTypeParameters) || - type.flags & 2097152 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) || - type.flags & 1572864 && couldUnionOrIntersectionContainTypeParameters(type)); + objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeParameters) || + objectFlags & 16 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) || + objectFlags & 32 || + type.flags & 196608 && couldUnionOrIntersectionContainTypeParameters(type)); } function couldUnionOrIntersectionContainTypeParameters(type) { if (type.couldContainTypeParameters === undefined) { @@ -25680,7 +27587,7 @@ var ts; return type.couldContainTypeParameters; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 1572864 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || type.flags & 196608 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function inferTypes(context, originalSource, originalTarget) { var typeParameters = context.signature.typeParameters; @@ -25702,8 +27609,16 @@ var ts; if (!couldContainTypeParameters(target)) { return; } - if (source.flags & 524288 && target.flags & 524288 && !(source.flags & 16 && target.flags & 16) || - source.flags & 1048576 && target.flags & 1048576) { + if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { + var sourceTypes = source.aliasTypeArguments; + var targetTypes = target.aliasTypeArguments; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + return; + } + if (source.flags & 65536 && target.flags & 65536 && !(source.flags & 16 && target.flags & 16) || + source.flags & 131072 && target.flags & 131072) { if (source === target) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -25731,7 +27646,7 @@ var ts; } } if (target.flags & 16384) { - if (source.flags & 134217728) { + if (source.flags & 8388608) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -25752,7 +27667,7 @@ var ts; } } } - else if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + else if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { var sourceTypes = source.typeArguments || emptyArray; var targetTypes = target.typeArguments || emptyArray; var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -25760,7 +27675,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 1572864) { + else if (target.flags & 196608) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter = void 0; @@ -25780,7 +27695,7 @@ var ts; inferiority--; } } - else if (source.flags & 1572864) { + else if (source.flags & 196608) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -25788,8 +27703,21 @@ var ts; } } else { + if (getObjectFlags(target) & 32) { + var constraintType = getConstraintTypeFromMappedType(target); + if (getObjectFlags(source) & 32) { + inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + return; + } + if (constraintType.flags & 16384) { + inferFromTypes(getIndexType(source), constraintType); + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return; + } + } source = getApparentType(source); - if (source.flags & 2588672) { + if (source.flags & 32768) { if (isInProcess(source, target)) { return; } @@ -25818,8 +27746,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)); @@ -25885,7 +27813,7 @@ var ts; reducedTypes.push(t); } } - return type.flags & 524288 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 65536 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function getInferenceCandidates(context, index) { var inferences = context.inferences[index]; @@ -25893,7 +27821,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]; @@ -25946,10 +27874,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: @@ -25966,7 +27894,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 173) { + if (node.kind === 177) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -25977,7 +27905,7 @@ var ts; case 70: case 98: return node; - case 173: + case 177: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -25986,19 +27914,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 || target.kind === 170) && + (target.kind === 223 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 173: - return target.kind === 173 && + case 177: + return target.kind === 177 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173) { + while (source.kind === 177) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26007,7 +27935,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 && + return target.kind === 177 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -26015,14 +27943,14 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173) { + if (expr.kind === 177) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 524288) { + if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456) { if (prop.isDiscriminantProperty === undefined) { @@ -26045,7 +27973,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 && + if (callExpression.expression.kind === 177 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26059,7 +27987,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 524288)) { + if (!(source.flags & 65536)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -26122,7 +28050,7 @@ var ts; type === falseType ? 3030404 : 1981828 : type === falseType ? 3145092 : 4193668; } - if (flags & 2588672) { + if (flags & 32768) { return isFunctionObjectType(type) ? strictNullChecks ? 6164448 : 8376288 : strictNullChecks ? 6166480 : 8378320; @@ -26140,7 +28068,7 @@ var ts; var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); } - if (flags & 1572864) { + if (flags & 196608) { return getTypeFactsOfTypes(type.types); } return 8388607; @@ -26156,7 +28084,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) || @@ -26167,19 +28095,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 === 175 || node.parent.kind === 257 ? 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); @@ -26190,21 +28118,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208: + case 212: return stringType; - case 209: + case 213: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188: - return getAssignedTypeOfBinaryExpression(parent); - case 182: - return undefinedType; - case 171: - return getAssignedTypeOfArrayLiteralElement(parent, node); case 192: - return getAssignedTypeOfSpreadElement(parent); - case 253: + return getAssignedTypeOfBinaryExpression(parent); + case 186: + return undefinedType; + case 175: + return getAssignedTypeOfArrayLiteralElement(parent, node); + case 196: + return getAssignedTypeOfSpreadExpression(parent); + case 257: return getAssignedTypeOfPropertyAssignment(parent); - case 254: + case 258: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -26212,11 +28140,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 ? + var type = pattern.kind === 172 ? 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) { @@ -26227,35 +28155,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 212) { return stringType; } - if (node.parent.parent.kind === 209) { + if (node.parent.parent.kind === 213) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 ? + return node.kind === 223 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 || node.kind === 170 ? + return node.kind === 223 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 && node.initializer && + return node.kind === 223 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 && node.parent.kind === 188 && + node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179: + case 183: return getReferenceCandidate(node.expression); - case 188: + case 192: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -26267,13 +28195,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 === 183 || + parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249) { + if (clause.kind === 253) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -26288,13 +28216,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 524288 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 65536 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 524288 && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 65536 && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 524288) { + if (source.flags & 65536) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -26308,8 +28236,11 @@ var ts; } return containsType(target.types, source); } + function forEachType(type, f) { + return type.flags & 65536 ? ts.forEach(type.types, f) : f(type); + } function filterType(type, f) { - if (type.flags & 524288) { + if (type.flags & 65536) { var types = type.types; var filtered = ts.filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered); @@ -26317,7 +28248,7 @@ var ts; return f(type) ? type : neverType; } function mapType(type, f) { - return type.flags & 524288 ? getUnionType(ts.map(type.types, f)) : f(type); + return type.flags & 65536 ? getUnionType(ts.map(type.types, f)) : f(type); } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -26343,7 +28274,7 @@ var ts; return incomplete ? { flags: 0, type: type } : type; } function createEvolvingArrayType(elementType) { - var result = createObjectType(2097152); + var result = createObjectType(256); result.elementType = elementType; return result; } @@ -26354,13 +28285,10 @@ var ts; var elementType = getBaseTypeOfLiteralType(checkExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } - function isEvolvingArrayType(type) { - return !!(type.flags & 2097152 && type.elementType); - } function createFinalArrayType(elementType) { return elementType.flags & 8192 ? autoArrayType : - createArrayType(elementType.flags & 524288 ? + createArrayType(elementType.flags & 65536 ? getUnionType(elementType.types, true) : elementType); } @@ -26368,17 +28296,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return getObjectFlags(type) & 256 ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? type.elementType : neverType; + return getObjectFlags(type) & 256 ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { var t = types_12[_i]; if (!(t.flags & 8192)) { - if (!isEvolvingArrayType(t)) { + if (!(getObjectFlags(t) & 256)) { return false; } hasEvolvingArrayType = true; @@ -26394,20 +28322,40 @@ 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 === 177 && (parent.name.text === "length" || + parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 178 && parent.expression === root && - parent.parent.kind === 188 && + parent.parent.kind === 192 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); return isLengthPushOrUnshift || isElementAssignment; } + function maybeTypePredicateCall(node) { + var links = getNodeLinks(node); + if (links.maybeTypePredicate === undefined) { + links.maybeTypePredicate = getMaybeTypePredicate(node); + } + return links.maybeTypePredicate; + } + function getMaybeTypePredicate(node) { + if (node.expression.kind !== 96) { + var funcType = checkNonNullExpression(node.expression); + if (funcType !== silentNeverType) { + var apparentType = getApparentType(funcType); + if (apparentType !== unknownType) { + var callSignatures = getSignaturesOfType(apparentType, 0); + return !!ts.forEach(callSignatures, function (sig) { return sig.typePredicate; }); + } + } + } + return false; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -26416,8 +28364,8 @@ var ts; var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { + var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -26462,7 +28410,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 !== 177) { flow = container.flowNode; continue; } @@ -26482,7 +28430,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)); } @@ -26493,7 +28441,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 524288) { + if (declaredType.flags & 65536) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -26505,15 +28453,15 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 ? + var expr = node.kind === 179 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (isEvolvingArrayType(type)) { + if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 175) { + if (node.kind === 179) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -26631,8 +28579,8 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 && - declaredType.flags & 524288 && + return expr.kind === 177 && + declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); } @@ -26665,10 +28613,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 === 187 && 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 === 187 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26714,7 +28662,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 2589185) { + if (type.flags & 33281) { return type; } if (assumeTrue) { @@ -26738,7 +28686,7 @@ var ts; if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 524288)) { + if (assumeTrue && !(type.flags & 65536)) { var targetType = typeofTypesByName[literal.text]; if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; @@ -26790,10 +28738,10 @@ var ts; } if (!targetType) { var constructSignatures = void 0; - if (rightType.flags & 65536) { + if (getObjectFlags(rightType) & 2) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 2097152) { + else if (getObjectFlags(rightType) & 16) { constructSignatures = getSignaturesOfType(rightType, 1); } if (constructSignatures && constructSignatures.length) { @@ -26809,7 +28757,7 @@ var ts; if (!assumeTrue) { return filterType(type, function (t) { return !isTypeInstanceOf(t, candidate); }); } - if (type.flags & 524288) { + if (type.flags & 65536) { var assignableType = filterType(type, function (t) { return isTypeInstanceOf(t, candidate); }); if (!(assignableType.flags & 8192)) { return assignableType; @@ -26822,7 +28770,7 @@ var ts; getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { return type; } var signature = getResolvedSignature(callExpression); @@ -26845,10 +28793,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 === 178 || invokedExpression.kind === 177) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -26863,15 +28811,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 177: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175: - return narrowTypeByTypePredicate(type, expr, assumeTrue); case 179: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 183: return narrowType(type, expr.expression, assumeTrue); - case 188: + case 192: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186: + case 190: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -26894,19 +28842,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 === 231 || + node.kind === 261 || + node.kind === 147) { return node; } } @@ -26937,7 +28879,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; } } @@ -26951,19 +28893,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 === 185) { 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); @@ -26972,7 +28918,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 222 + && declaration_1.kind === 226 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -26984,11 +28930,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193) { + else if (declaration_1.kind === 197) { 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; } @@ -27003,15 +28949,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 === 184 || + flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -27032,7 +28989,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; @@ -27047,7 +29004,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 252) { + symbol.valueDeclaration.parent.kind === 256) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27065,8 +29022,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 207 && - ts.getAncestor(symbol.valueDeclaration, 220).parent === container && + if (container.kind === 211 && + ts.getAncestor(symbol.valueDeclaration, 224).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27078,14 +29035,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 179) { + while (current.parent.kind === 183) { 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 === 190 || current.parent.kind === 191)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -27104,7 +29061,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; } @@ -27138,7 +29095,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)) { @@ -27148,29 +29105,29 @@ var ts; } } } - if (container.kind === 181) { + if (container.kind === 185) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 226: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 225: + case 229: 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; } @@ -27179,7 +29136,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 180 && + if (container.kind === 184 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27214,27 +29171,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 === 274) { 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 === 277) { 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 === 179 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 181) { + while (container && container.kind === 185) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27243,16 +29200,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 === 176)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27267,7 +29224,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; } @@ -27278,7 +29235,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172) { + if (container.parent.kind === 176) { 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; @@ -27296,7 +29253,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; } @@ -27308,24 +29265,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 === 176) { 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; } } } @@ -27333,7 +29290,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -27389,7 +29346,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; @@ -27400,11 +29357,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_15 = declaration.propertyName || declaration.name; + var name_22 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_15)) { - var text = getTextOfPropertyName(name_15); + !ts.isBindingPattern(name_22)) { + var text = ts.getTextOfPropertyName(name_22); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -27441,7 +29398,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; @@ -27450,8 +29407,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); @@ -27470,7 +29427,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177) { + if (template.parent.kind === 181) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27501,7 +29458,7 @@ var ts; return undefined; } function applyToContextualType(type, mapper) { - if (!(type.flags & 524288)) { + if (!(type.flags & 65536)) { return mapper(type); } var types = type.types; @@ -27526,7 +29483,7 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = t.flags & 4161536 ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 229376 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } @@ -27534,7 +29491,7 @@ var ts; return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 524288 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 65536 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -27578,13 +29535,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246) { + if (attribute.kind === 250) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247) { + else if (attribute.kind === 251) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -27602,56 +29559,70 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219: - case 143: + case 223: + case 144: + case 147: case 146: - case 145: - case 170: + case 174: return getContextualTypeForInitializerExpression(node); - case 181: - case 212: + case 185: + case 216: return getContextualTypeForReturnExpression(node); - case 191: + case 195: 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: + case 180: + return getContextualTypeForArgument(parent, node); + case 182: + case 200: + return getTypeFromTypeNode(parent.type); + case 192: + return getContextualTypeForBinaryOperand(node); + case 257: + case 258: + return getContextualTypeForObjectLiteralElement(parent); + case 175: + return getContextualTypeForElementExpression(node); + case 193: + return getContextualTypeForConditionalOperand(node); + case 202: + ts.Debug.assert(parent.parent.kind === 194); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 183: return getContextualType(parent); - case 248: + case 252: return getContextualType(parent); - case 246: - case 247: + case 250: + case 251: return getContextualTypeForJsxAttribute(parent); } return undefined; } - function getNonGenericSignature(type) { + function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { var signature = signatures[0]; - if (!signature.typeParameters) { + if (!signature.typeParameters && !isAritySmaller(signature, node)) { return signature; } } } + function isAritySmaller(signature, target) { + var targetParameterCount = 0; + for (; targetParameterCount < target.parameters.length; targetParameterCount++) { + var param = target.parameters[targetParameterCount]; + if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { + break; + } + } + if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { + targetParameterCount--; + } + var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; + return sourceLength < targetParameterCount; + } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 || node.kind === 181; + return node.kind === 184 || node.kind === 185; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27664,19 +29635,19 @@ 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; } - if (!(type.flags & 524288)) { - return getNonGenericSignature(type); + if (!(type.flags & 65536)) { + return getNonGenericSignature(type, node); } var signatureList; var types = type.types; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var current = types_14[_i]; - var signature = getNonGenericSignature(current); + var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { signatureList = [signature]; @@ -27700,13 +29671,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 === 174 && !!node.initializer) || + (node.kind === 192 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27715,7 +29686,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 === 196) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27727,7 +29698,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192; + hasSpreadElement = hasSpreadElement || e.kind === 196; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27738,7 +29709,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 === 173 || pattern.kind === 175)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27746,7 +29717,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194) { + if (patternElement.kind !== 198) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27763,7 +29734,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); @@ -27805,9 +29776,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 === 172 || contextualType.pattern.kind === 176); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27815,25 +29788,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 === 257 || + memberDecl.kind === 258 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253) { + if (memberDecl.kind === 257) { 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 === 258); 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 === 257 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -27841,8 +29814,7 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & 2588672 && contextualType.isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; @@ -27860,8 +29832,25 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 259) { + 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)) { @@ -27889,18 +29878,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 : 16777216; - result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024); - if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + 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 |= 128; + if (patternWithComputedProperties) { + result.objectFlags |= 512; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144)) { + propagatedFlags |= (result.flags & 14680064); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -27917,13 +29921,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248: + case 252: checkJsxExpression(child); break; - case 242: + case 246: checkJsxElement(child); break; - case 243: + case 247: checkJsxSelfClosingElement(child); break; } @@ -27934,7 +29938,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 173 || tagName.kind === 98) { + if (tagName.kind === 177 || tagName.kind === 98) { return false; } else { @@ -27950,7 +29954,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; } @@ -28025,7 +30029,7 @@ var ts; return links.resolvedSymbol; } function getJsxElementInstanceType(node, valueType) { - ts.Debug.assert(!(valueType.flags & 524288)); + ts.Debug.assert(!(valueType.flags & 65536)); if (isTypeAny(valueType)) { return anyType; } @@ -28064,7 +30068,7 @@ var ts; if (!elemType) { elemType = checkExpression(node.tagName); } - if (elemType.flags & 524288) { + if (elemType.flags & 65536) { var types = elemType.types; return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); @@ -28126,7 +30130,7 @@ var ts; else if (isTypeAny(attributesType) || (attributesType === unknownType)) { return attributesType; } - else if (attributesType.flags & 524288) { + else if (attributesType.flags & 65536) { error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } @@ -28203,20 +30207,23 @@ 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) { - getSymbolLinks(reactSym).referenced = true; + reactSym.isReferenced = true; + if (reactSym.flags & 8388608 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + markAliasSymbolAsReferenced(reactSym); + } } var targetAttributesType = getJsxElementAttributesType(node); 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 === 250) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247); + ts.Debug.assert(node.attributes[i].kind === 251); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -28242,7 +30249,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; @@ -28253,11 +30260,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 === 177 || node.kind === 223 ? 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; } @@ -28294,7 +30301,7 @@ var ts; if (type.flags & 16384 && type.isThisType) { type = getConstraintOfTypeParameter(type); } - if (!(getTargetType(type).flags & (32768 | 65536) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & 3 && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -28320,6 +30327,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) { @@ -28336,44 +30370,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 !== 177 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && - !(prop.flags & 8192 && propType.flags & 524288)) { + !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - return getFlowTypeOfReference(node, propType, true, undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 524288 && !(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 === 177 ? node.expression : node.left; var type = checkExpression(left); @@ -28387,7 +30406,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220) { + if (initializer.kind === 224) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -28402,14 +30421,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 === 212 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28423,9 +30442,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 === 180 && 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); @@ -28435,71 +30456,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) { @@ -28532,10 +30499,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177) { + if (node.kind === 181) { checkExpression(node.template); } - else if (node.kind !== 144) { + else if (node.kind !== 145) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28557,19 +30524,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_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -28586,7 +30553,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 === 196) { return i; } } @@ -28599,11 +30566,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177) { + if (node.kind === 181) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190) { + if (tagExpression.template.kind === 194) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28615,7 +30582,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); @@ -28623,7 +30590,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 176); + ts.Debug.assert(callExpression.kind === 180); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28646,7 +30613,7 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -28682,7 +30649,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 !== 198) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -28729,7 +30696,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 !== 180) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28742,7 +30709,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 !== 198) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -28757,28 +30724,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 175) { + if (node.kind === 179) { var callee = node.expression; - if (callee.kind === 173) { + if (callee.kind === 177) { return callee.expression; } - else if (callee.kind === 174) { + else if (callee.kind === 178) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 177) { + if (node.kind === 181) { var template = node.template; args = [undefined]; - if (template.kind === 190) { + if (template.kind === 194) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144) { + else if (node.kind === 145) { return undefined; } else { @@ -28787,21 +30754,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 226: + case 197: 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; } } @@ -28810,48 +30777,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 226) { 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 === 226) { 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; @@ -28868,20 +30835,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 226) { 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); } @@ -28902,26 +30869,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 === 181) { 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 === 181)) { 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 === 181) { return node.template; } else { @@ -28929,8 +30896,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177; - var isDecorator = node.kind === 144; + var isTaggedTemplate = node.kind === 181; + var isDecorator = node.kind === 145; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -28960,7 +30927,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -28979,7 +30946,7 @@ var ts; else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { var typeArguments_2 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNodeNoAlias), true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -29000,7 +30967,7 @@ var ts; var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNodeNoAlias)); + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); } return candidate; } @@ -29032,7 +30999,7 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNodeNoAlias); + typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { @@ -29121,7 +31088,7 @@ var ts; return true; } if (!numCallSignatures && !numConstructSignatures) { - if (funcType.flags & 524288) { + if (funcType.flags & 65536) { return false; } return isTypeAssignableTo(funcType, globalFunctionType); @@ -29228,16 +31195,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222: - case 193: + case 226: + case 197: 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; } } @@ -29264,13 +31231,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175: + case 179: return resolveCallExpression(node, candidatesOutArray); - case 176: + case 180: return resolveNewExpression(node, candidatesOutArray); - case 177: + case 181: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144: + case 145: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29302,12 +31269,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 176) { + if (node.kind === 180) { 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) : @@ -29321,13 +31288,33 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && - ts.isRequireCall(node, true) && - !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { + if (ts.isInJavaScriptFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); } + function isCommonJsRequire(node) { + if (!ts.isRequireCall(node, true)) { + return false; + } + var resolvedRequire = resolveName(node.expression, node.expression.text, 107455, undefined, undefined); + if (!resolvedRequire) { + return true; + } + if (resolvedRequire.flags & 8388608) { + return false; + } + var targetDeclarationKind = resolvedRequire.flags & 16 + ? 225 + : resolvedRequire.flags & 3 + ? 223 + : 0; + if (targetDeclarationKind !== 0) { + var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + return ts.isInAmbientContext(decl); + } + return false; + } function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } @@ -29413,8 +31400,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 === 172 || + parameter.valueDeclaration.name.kind === 173)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29441,7 +31428,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; @@ -29453,7 +31440,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200) { + if (func.body.kind !== 204) { 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); @@ -29532,7 +31519,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29561,7 +31548,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 || func.kind === 181)) { + func.kind === 184 || func.kind === 185)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29578,7 +31565,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 !== 204 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29605,9 +31592,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 === 184) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29641,14 +31628,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) { @@ -29658,7 +31645,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200) { + if (node.body.kind === 204) { checkSourceElement(node.body); } else { @@ -29693,10 +31680,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 173 || expr.kind === 174) && + (expr.kind === 177 || expr.kind === 178) && 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); } @@ -29705,44 +31692,24 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 || expr.kind === 174) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 177 || expr.kind === 178) { + 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 === 237; } } } 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 !== 177 && node.kind !== 178) { 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) { @@ -29759,7 +31726,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)) { @@ -29794,7 +31761,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; } @@ -29807,7 +31774,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; } @@ -29815,7 +31782,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 1572864) { + if (type.flags & 196608) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -29830,7 +31797,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 524288) { + if (type.flags & 65536) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -29840,7 +31807,7 @@ var ts; } return true; } - if (type.flags & 1048576) { + if (type.flags & 131072) { var types = type.types; for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { var t = types_17[_a]; @@ -29852,7 +31819,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (2588672 | 2097152) && type.symbol && isConstEnumSymbol(type.symbol); + return getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; @@ -29876,36 +31843,36 @@ var ts; if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 | 340 | 512)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } 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 === 257 || property.kind === 258) { + var name_23 = property.name; + if (name_23.kind === 142) { + checkComputedPropertyName(name_23); } - if (isComputedNonLiteralName(name_17)) { + if (isComputedNonLiteralName(name_23)) { return undefined; } - var text = getTextOfPropertyName(name_17); + 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 === 258) { return checkDestructuringAssignment(property, type); } else { @@ -29913,7 +31880,12 @@ 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_23, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_23)); + } + } + else if (property.kind === 259) { + if (property.expression.kind !== 70) { + error(property.expression, ts.Diagnostics.An_object_rest_element_must_be_an_identifier); } } else { @@ -29931,8 +31903,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 !== 198) { + if (element.kind !== 196) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -29954,11 +31926,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 === 192 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -29971,7 +31943,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254) { + if (exprOrAssignment.kind === 258) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -29985,21 +31957,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 && target.operatorToken.kind === 57) { + if (target.kind === 192 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172) { + if (target.kind === 176) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171) { + if (target.kind === 175) { 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; @@ -30010,35 +31982,35 @@ var ts; case 70: case 9: case 11: - case 177: - case 190: + case 181: + case 194: case 12: case 8: case 100: case 85: case 94: - case 136: - case 180: - case 193: - case 181: - case 171: - case 172: - case 183: + case 137: + case 184: case 197: - case 243: - case 242: + case 185: + case 175: + case 176: + case 187: + case 201: + case 247: + case 246: return true; - case 189: + case 193: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188: + case 192: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186: - case 187: + case 190: + case 191: switch (node.operator) { case 50: case 36: @@ -30047,9 +32019,9 @@ var ts; return true; } return false; - case 184: - case 178: - case 196: + case 188: + case 182: + case 200: default: return false; } @@ -30069,7 +32041,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 === 176 || left.kind === 175)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -30226,8 +32198,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); } } @@ -30253,7 +32224,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)) { @@ -30327,8 +32298,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 === 182 || node.kind === 200; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30354,14 +32325,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); @@ -30384,7 +32355,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140) { + if (node.kind === 141) { type = checkQualifiedName(node); } else { @@ -30392,9 +32363,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 === 177 && node.parent.expression === node) || + (node.parent.kind === 178 && 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); } @@ -30416,66 +32387,66 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 190: + case 194: 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); case 175: + return checkArrayLiteral(node, contextualMapper); case 176: - return checkCallExpression(node); + return checkObjectLiteral(node, contextualMapper); 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 checkPropertyAccessExpression(node); case 178: - case 196: - return checkAssertion(node); + return checkIndexedAccess(node); + case 179: + case 180: + return checkCallExpression(node); + case 181: + return checkTaggedTemplateExpression(node); + case 183: + return checkExpression(node.expression, contextualMapper); case 197: - return checkNonNullAssertion(node); - case 182: - return checkDeleteExpression(node); + return checkClassExpression(node); case 184: - return checkVoidExpression(node); case 185: - return checkAwaitExpression(node); - case 186: - return checkPrefixUnaryExpression(node); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 187: - return checkPostfixUnaryExpression(node); + return checkTypeOfExpression(node); + case 182: + case 200: + return checkAssertion(node); + case 201: + return checkNonNullAssertion(node); + case 186: + return checkDeleteExpression(node); case 188: - return checkBinaryExpression(node, contextualMapper); + return checkVoidExpression(node); case 189: - return checkConditionalExpression(node, contextualMapper); - case 192: - return checkSpreadElementExpression(node, contextualMapper); - case 194: - return undefinedWideningType; + return checkAwaitExpression(node); + case 190: + return checkPrefixUnaryExpression(node); case 191: + return checkPostfixUnaryExpression(node); + case 192: + return checkBinaryExpression(node, contextualMapper); + case 193: + return checkConditionalExpression(node, contextualMapper); + case 196: + return checkSpreadExpression(node, contextualMapper); + case 198: + return undefinedWideningType; + case 195: return checkYieldExpression(node); - case 248: + case 252: return checkJsxExpression(node); - case 242: + case 246: return checkJsxElement(node); - case 243: + case 247: return checkJsxSelfClosingElement(node); - case 244: + case 248: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30496,7 +32467,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); } } @@ -30507,7 +32478,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); } } @@ -30519,9 +32490,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 === 225 || + node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -30562,9 +32533,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_24 = _a[_i].name; + if (ts.isBindingPattern(name_24) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -30577,16 +32548,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181: - case 152: - case 221: - case 180: - case 157: + case 185: + case 153: + case 225: + case 184: + case 158: + case 149: case 148: - case 147: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -30596,27 +32567,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_19 = element.name; - if (name_19.kind === 70 && - name_19.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_19.kind === 169 || - name_19.kind === 168) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { + else if (name_25.kind === 173 || + name_25.kind === 172) { + 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 === 225 || node.kind === 159 || + node.kind === 153 || node.kind === 150 || + node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30628,10 +32599,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; } @@ -30658,17 +32629,11 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); 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)) { @@ -30682,13 +32647,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; } @@ -30714,7 +32679,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: @@ -30736,7 +32701,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223) { + if (node.kind === 227) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30751,7 +32716,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; } @@ -30759,7 +32724,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131: + case 132: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30818,12 +32783,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 !== 184 && n.kind !== 225) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 && + return n.kind === 147 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30843,7 +32808,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 === 207 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -30866,18 +32831,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)) { @@ -30891,11 +32856,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 !== 176) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -30925,7 +32890,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -30976,14 +32941,25 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } + function checkMappedType(node) { + checkSourceElement(node.typeParameter); + checkSourceElement(node.type); + var type = getTypeFromMappedTypeNode(node); + var constraintType = getConstraintTypeFromMappedType(type); + var keyType = constraintType.flags & 16384 ? getApparentTypeOfTypeParameter(constraintType) : constraintType; + checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint); + } 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 !== 227 && + n.parent.kind !== 226 && + n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31060,7 +33036,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; @@ -31093,11 +33069,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 === 227 || 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 === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31208,16 +33184,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223: + case 227: return 2097152; - case 226: + case 230: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 222: - case 225: + case 226: + case 229: return 2097152 | 1048576; - case 230: + case 234: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31244,7 +33220,7 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (promise.flags & 131072) { + if (getObjectFlags(promise) & 4) { if (promise.target === tryGetGlobalPromiseType() || promise.target === getGlobalPromiseLikeType()) { return promise.typeArguments[0]; @@ -31281,7 +33257,7 @@ var ts; function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); function checkAwaitedTypeWorker(type) { - if (type.flags & 524288) { + if (type.flags & 65536) { var types = []; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -31309,51 +33285,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); @@ -31365,22 +33340,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222: + case 226: 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]); @@ -31388,29 +33363,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) { @@ -31425,21 +33386,27 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 222: + case 226: 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; } } @@ -31458,7 +33425,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)) { @@ -31500,43 +33467,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 261: + case 230: checkUnusedModuleMembers(node); break; - case 222: - case 193: + case 226: + case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223: + case 227: checkUnusedTypeParameters(node); break; - case 200: - case 228: - case 207: - case 208: - case 209: + case 204: + case 232: + case 211: + case 212: + case 213: checkUnusedLocalsAndParameters(node); break; - case 149: - case 180: - case 221: - case 181: - case 148: case 150: + case 184: + case 225: + case 185: + 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; } @@ -31545,43 +33512,57 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_1 = function (key) { + if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 143) { - var parameter = local.valueDeclaration; + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { + !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return error(d.name || d, ts.Diagnostics._0_is_declared_but_never_used, local.name); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } }; for (var key in node.locals) { - _loop_1(key); + _loop_3(key); } } } - function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; + function errorUnusedLocal(node, name) { + if (isIdentifierThatStartsWithUnderScore(node)) { + var declaration = ts.getRootDeclaration(node.parent); + if (declaration.kind === 223 && + (declaration.parent.parent.kind === 212 || + declaration.parent.parent.kind === 213)) { + return; + } + } + error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + } + function parameterNameStartsWithUnderscore(parameterName) { + return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); + } + function isIdentifierThatStartsWithUnderScore(node) { + return node.kind === 70 && node.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { 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) { @@ -31626,7 +33607,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 200) { + if (node.kind === 204) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31648,19 +33629,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; @@ -31711,11 +33692,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 261 && 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)); } } @@ -31723,11 +33704,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 261 && 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)); } } @@ -31735,7 +33716,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 219 && !node.initializer) { + if (node.kind === 223 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31745,25 +33726,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, 224); + var container = varDeclList.parent.kind === 205 && 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 === 204 && ts.isFunctionLike(container.parent) || + container.kind === 231 || + container.kind === 230 || + container.kind === 261); 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_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); @@ -31772,7 +33753,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 173) { + if (n.kind === 177) { return visit(n.expression); } else if (n.kind === 70) { @@ -31786,7 +33767,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; } @@ -31795,7 +33776,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; @@ -31817,33 +33798,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 === 174) { + 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_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); + var name_27 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_27)); + markPropertyAsReferenced(property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.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 !== 212) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31852,7 +33834,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 !== 212) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -31870,9 +33852,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 === 223 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -31882,8 +33864,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 === 223) || + (left.kind === 223 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -31910,7 +33892,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 === 176) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -31929,7 +33911,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202) { + if (node.thenStatement.kind === 206) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -31946,12 +33928,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220) { + if (node.initializer && node.initializer.kind === 224) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -31969,18 +33951,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 175 || varExpr.kind === 176) { 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); } @@ -31993,7 +33975,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { 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); @@ -32003,18 +33985,18 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 175 || varExpr.kind === 176) { 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); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -32067,7 +34049,7 @@ var ts; } var typeAsIterable = type; if (!typeAsIterable.iterableElementType) { - if ((type.flags & 131072) && type.target === getGlobalIterableType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableType()) { typeAsIterable.iterableElementType = type.typeArguments[0]; } else { @@ -32093,7 +34075,7 @@ var ts; } var typeAsIterator = type; if (!typeAsIterator.iteratorElementType) { - if ((type.flags & 131072) && type.target === getGlobalIteratorType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIteratorType()) { typeAsIterator.iteratorElementType = type.typeArguments[0]; } else { @@ -32128,7 +34110,7 @@ var ts; if (isTypeAny(type)) { return undefined; } - if ((type.flags & 131072) && type.target === getGlobalIterableIteratorType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableIteratorType()) { return type.typeArguments[0]; } return getElementTypeOfIterable(type, undefined) || @@ -32137,8 +34119,12 @@ var ts; function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { ts.Debug.assert(languageVersion < 2); var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 524288) { - arrayType = getUnionType(ts.filter(arrayOrStringType.types, function (t) { return !(t.flags & 34); }), true); + if (arrayOrStringType.flags & 65536) { + var arrayTypes = arrayOrStringType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, true); + } } else if (arrayOrStringType.flags & 34) { arrayType = neverType; @@ -32176,7 +34162,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; @@ -32198,12 +34184,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); } @@ -32221,14 +34207,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); } } @@ -32245,8 +34231,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 === 254 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -32258,11 +34245,17 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249) { + if (produceDiagnostics && clause.kind === 253) { 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); @@ -32278,7 +34271,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 && current.label.text === node.label.text) { + if (current.kind === 219 && 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; @@ -32304,22 +34297,20 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 70) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { + if (catchClause.variableDeclaration.type) { grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); } else if (catchClause.variableDeclaration.initializer) { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + var blockLocals = catchClause.block.locals; + if (blockLocals) { + for (var caughtName in catchClause.locals) { + var blockLocal = blockLocals[caughtName]; + if (blockLocal && (blockLocal.flags & 2) !== 0) { + grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); + } } } } @@ -32341,7 +34332,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 32768 && ts.isClassLike(type.symbol.valueDeclaration)) { + if (getObjectFlags(type) & 1 && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -32356,7 +34347,7 @@ var ts; var errorNode; if (stringIndexType && numberIndexType) { errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 65536)) { + if (!errorNode && (getObjectFlags(type) & 2)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } @@ -32372,13 +34363,13 @@ 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) { errorNode = indexDeclaration; } - else if (containingType.flags & 65536) { + else if (getObjectFlags(containingType) & 2) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } @@ -32423,7 +34414,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 === 226 || declaration.kind === 227) { if (!firstDecl) { firstDecl = declaration; } @@ -32486,7 +34477,9 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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)) { + if (baseType_1.symbol.valueDeclaration && + !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && + baseType_1.symbol.valueDeclaration.kind === 226) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -32511,8 +34504,8 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = (t.flags & 131072) ? t.target : t; - if (declaredType.flags & (32768 | 65536)) { + var declaredType = getObjectFlags(t) & 4 ? t.target : t; + if (getObjectFlags(declaredType) & 3) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -32534,7 +34527,7 @@ var ts; if (declaration && ts.getModifierFlags(declaration) & 8) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { - error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); } } } @@ -32560,7 +34553,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 === 197) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32604,7 +34597,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 || kind === 151; + return kind === 151 || kind === 152; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32642,8 +34635,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 }; @@ -32671,7 +34664,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32700,6 +34693,7 @@ var ts; function checkTypeAliasDeclaration(node) { checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } function computeEnumMemberValues(node) { @@ -32716,7 +34710,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); } @@ -32766,7 +34760,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186: + case 190: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -32777,7 +34771,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 188: + case 192: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32802,11 +34796,11 @@ var ts; return undefined; case 8: return +e.text; - case 179: + case 183: return evalConstant(e.expression); case 70: - case 174: - case 173: + case 178: + case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -32817,7 +34811,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174) { + if (e.kind === 178) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32834,7 +34828,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 173) { + else if (current.kind === 177) { current = current.expression; } else { @@ -32894,7 +34888,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 225) { + if (declaration.kind !== 229) { return false; } var enumDeclaration = declaration; @@ -32917,8 +34911,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 === 226 || + (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -32977,7 +34971,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, 226); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33020,36 +35014,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201: + case 205: 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 240: + case 241: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230: - case 231: + case 234: + case 235: 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 174: + case 223: + 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 224: + case 229: + case 225: + case 227: + case 230: + case 228: if (isGlobalAugmentation) { return; } @@ -33067,12 +35061,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 177: do { node = node.expression; } while (node.kind !== 70); @@ -33085,9 +35079,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 === 231 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 && !inAmbientExternalModule) { + error(moduleName, node.kind === 241 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33108,7 +35102,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 === 243 ? 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)); @@ -33135,7 +35129,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 237) { checkImportBinding(importClause.namedBindings); } else { @@ -33186,8 +35180,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 === 231 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -33200,7 +35194,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 === 261 || node.parent.kind === 231 || node.parent.kind === 230; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33223,8 +35217,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 === 261 ? node.parent : node.parent.parent; + if (container.kind === 230 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -33291,7 +35285,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 && declaration.kind !== 148) || + return (declaration.kind !== 225 && declaration.kind !== 149) || !!declaration.body; } } @@ -33302,118 +35296,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 230: case 226: - case 222: - case 223: - case 221: + case 227: + case 225: 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 169: + return checkIndexedAccessType(node); case 170: - return checkBindingElement(node); - case 222: - return checkClassDeclaration(node); - case 223: - return checkInterfaceDeclaration(node); - case 224: - return checkTypeAliasDeclaration(node); + return checkMappedType(node); case 225: - return checkEnumDeclaration(node); - case 226: - return checkModuleDeclaration(node); + return checkFunctionDeclaration(node); + case 204: case 231: - return checkImportDeclaration(node); - case 230: - return checkImportEqualsDeclaration(node); - case 237: - return checkExportDeclaration(node); - case 236: - return checkExportAssignment(node); - case 202: - checkGrammarStatementInAmbientContext(node); - return; + return checkBlock(node); + case 205: + return checkVariableStatement(node); + case 207: + return checkExpressionStatement(node); + case 208: + return checkIfStatement(node); + case 209: + return checkDoStatement(node); + case 210: + return checkWhileStatement(node); + case 211: + return checkForStatement(node); + case 212: + return checkForInStatement(node); + case 213: + return checkForOfStatement(node); + case 214: + case 215: + return checkBreakOrContinueStatement(node); + case 216: + return checkReturnStatement(node); + case 217: + return checkWithStatement(node); case 218: + return checkSwitchStatement(node); + case 219: + return checkLabeledStatement(node); + case 220: + return checkThrowStatement(node); + case 221: + return checkTryStatement(node); + case 223: + return checkVariableDeclaration(node); + case 174: + return checkBindingElement(node); + case 226: + return checkClassDeclaration(node); + case 227: + return checkInterfaceDeclaration(node); + case 228: + return checkTypeAliasDeclaration(node); + case 229: + return checkEnumDeclaration(node); + case 230: + return checkModuleDeclaration(node); + case 235: + return checkImportDeclaration(node); + case 234: + return checkImportEqualsDeclaration(node); + case 241: + return checkExportDeclaration(node); + case 240: + return checkExportAssignment(node); + case 206: checkGrammarStatementInAmbientContext(node); return; - case 240: + case 222: + checkGrammarStatementInAmbientContext(node); + return; + case 244: return checkMissingDeclaration(node); } } @@ -33426,17 +35425,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 184: + case 185: + case 149: case 148: - case 147: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150: case 151: + case 152: checkAccessorDeferred(node); break; - case 193: + case 197: checkClassExpressionDeferred(node); break; } @@ -33490,8 +35489,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(); @@ -33508,7 +35518,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 && node.parent.statement === node) { + if (node.parent.kind === 217 && node.parent.statement === node) { return true; } node = node.parent; @@ -33530,28 +35540,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 225: + case 229: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 193: + case 197: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 222: - case 223: + case 226: + case 227: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 180: + case 184: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33590,27 +35600,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142: - case 222: - case 223: - case 224: - case 225: + case 143: + case 226: + case 227: + case 228: + case 229: 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 === 272); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173) { + while (node.parent && node.parent.kind === 177) { node = node.parent; } - return node.parent && node.parent.kind === 195; + return node.parent && node.parent.kind === 199; } function forEachEnclosingClass(node, callback) { var result; @@ -33627,13 +35637,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 === 234) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 240) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33645,7 +35655,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 === 177) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33657,11 +35667,11 @@ var ts; default: } } - if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 240 && 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 !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 234); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -33670,7 +35680,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 195) { + if (entityName.parent.kind === 199) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33692,14 +35702,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 173) { + else if (entityName.kind === 177) { 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); @@ -33708,19 +35718,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 === 272) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 246) { + else if (entityName.parent.kind === 250) { 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 === 261) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -33736,8 +35746,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 === 174 && + node.parent.parent.kind === 172 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33748,8 +35758,8 @@ var ts; } switch (node.kind) { case 70: - case 173: - case 140: + case 177: + case 141: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -33762,18 +35772,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 === 235 || node.parent.kind === 241) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33781,7 +35791,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 174 && node.parent.argumentExpression === node) { + if (node.parent.kind === 178 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33795,7 +35805,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 254) { + if (location && location.kind === 258) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -33845,20 +35855,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 === 176 || expr.kind === 175); + if (expr.parent.kind === 213) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 188) { + if (expr.parent.kind === 192) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 253) { + if (expr.parent.kind === 257) { 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 === 175); 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); @@ -33894,9 +35904,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_23 = symbol.name; + var name_29 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_23); + var symbol = getPropertyOfType(t, name_29); if (symbol) { symbols_3.push(symbol); } @@ -33904,6 +35914,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) { @@ -33961,7 +35975,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -33999,7 +36013,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 === 204 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34039,16 +36053,16 @@ var ts; return true; } switch (node.kind) { - case 230: - case 232: - case 233: - case 235: - case 239: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 234: + case 236: case 237: + case 239: + case 243: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 241: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236: + case 240: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -34058,7 +36072,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 !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -34109,7 +36123,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255) { + if (node.kind === 260) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -34121,7 +36135,7 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 2588672 && getSignaturesOfType(type, 0).length > 0; + return type.flags & 32768 && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); @@ -34203,9 +36217,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_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -34225,7 +36239,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 16777216); + return !!(type.flags & 96 && type.flags & 1048576); } return false; } @@ -34276,13 +36290,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 === 177) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34304,6 +36319,9 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + return undefined; + } } } return typeReferenceDirectives; @@ -34314,15 +36332,15 @@ var ts; } var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -34341,7 +36359,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256); + return ts.getDeclarationOfKind(moduleSymbol, 261); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -34371,7 +36389,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) { @@ -34440,9 +36458,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) { @@ -34477,7 +36499,7 @@ var ts; function createThenableType() { var thenPropertySymbol = createSymbol(67108864 | 4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(2097152); + var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; @@ -34489,14 +36511,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); @@ -34513,17 +36535,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 !== 229 && node.parent.kind === 226) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -34549,7 +36571,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 === 231 || node.parent.kind === 261) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -34572,10 +36594,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 === 231 || node.parent.kind === 261) { 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) { @@ -34584,11 +36606,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; @@ -34607,10 +36629,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 === 226) { 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; @@ -34622,13 +36644,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 === 226) { 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 === 231) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -34638,14 +36660,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 !== 226) { + 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 === 226 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34664,7 +36686,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; @@ -34672,7 +36694,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"); } @@ -34687,13 +36709,13 @@ var ts; } return; } - else if ((node.kind === 231 || node.kind === 230) && flags & 2) { + else if ((node.kind === 235 || node.kind === 234) && 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) { @@ -34709,37 +36731,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 146: + case 149: + case 148: + case 155: case 230: - case 237: - case 236: - case 180: - case 181: - case 143: + case 235: + case 234: + case 241: + case 240: + case 184: + case 185: + case 144: return false; default: - if (node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 231 || node.parent.kind === 261) { 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; case 225: + return nodeHasAnyModifiersExcept(node, 119); + case 226: + return nodeHasAnyModifiersExcept(node, 116); + case 227: + case 205: + case 228: + return true; + case 229: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -34752,10 +36774,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148: - case 221: - case 180: - case 181: + case 149: + case 225: + case 184: + case 185: if (!node.asteriskToken) { return false; } @@ -34817,7 +36839,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181) { + if (node.kind === 185) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34852,7 +36874,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) { @@ -34879,7 +36901,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 === 198) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -34949,19 +36971,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 === 192 && 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 === 225 || + node.kind === 184 || + node.kind === 149); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -34986,42 +37008,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 === 259) { + continue; } - if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { + var name_30 = prop.name; + if (name_30.kind === 142) { + checkGrammarComputedPropertyName(name_30); + } + if (prop.kind === 258 && !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 === 257 || prop.kind === 258) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_24.kind === 8) { - checkGrammarNumericLiteral(name_24); + 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_24); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); if (effectiveName === undefined) { continue; } @@ -35031,18 +37056,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_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_24, 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_24, 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); } } } @@ -35051,19 +37076,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 === 251) { continue; } var jsxAttr = attr; - var name_25 = jsxAttr.name; - if (!seen[name_25.text]) { - seen[name_25.text] = true; + var name_31 = jsxAttr.name; + if (!seen[name_31.text]) { + seen[name_31.text] = true; } else { - return grammarErrorOnNode(name_25, 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 === 252 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -35072,7 +37097,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220) { + if (forInOrOfStatement.initializer.kind === 224) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35080,20 +37105,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 + var diagnostic = forInOrOfStatement.kind === 212 ? 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 === 212 ? 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 === 212 ? 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); @@ -35117,11 +37142,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); } @@ -35140,10 +37165,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); } } @@ -35158,7 +37183,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172) { + if (node.parent.kind === 176) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -35174,10 +37199,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 === 227) { 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); } } @@ -35188,9 +37213,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215: + case 219: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 210 + var isMisplacedContinueLabel = node.kind === 214 && !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); @@ -35198,8 +37223,8 @@ var ts; return false; } break; - case 214: - if (node.kind === 211 && !node.label) { + case 218: + if (node.kind === 215 && !node.label) { return false; } break; @@ -35212,13 +37237,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 + var message = node.kind === 215 ? 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 === 215 ? 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); @@ -35228,9 +37253,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 === 173 || node.name.kind === 172) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35240,11 +37265,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 190 && 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 !== 212 && node.parent.parent.kind !== 213) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35301,15 +37326,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204: - case 205: - case 206: - case 213: - case 207: case 208: case 209: + case 210: + case 217: + case 211: + case 212: + case 213: return false; - case 215: + case 219: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35364,7 +37389,7 @@ var ts; return true; } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 227) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35372,7 +37397,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; } @@ -35385,13 +37410,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 === 227 || + node.kind === 228 || + node.kind === 235 || + node.kind === 234 || + node.kind === 241 || + node.kind === 240 || + node.kind === 233 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35400,7 +37425,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 === 205) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35419,7 +37444,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { 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); @@ -35458,49 +37483,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[182] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196] = [ + _a[200] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197] = [ + _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225] = [ + _a[229] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227] = [ + _a[231] = [ { name: "statements", test: ts.isStatement } ], - _a[230] = [ + _a[234] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241] = [ + _a[245] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255] = [ + _a[260] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -35513,41 +37538,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 <= 171)) { return initial; } var result = initial; switch (node.kind) { - case 199: - case 202: - case 194: - case 218: - case 287: + case 203: + case 206: + case 198: + case 222: + case 292: 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); @@ -35556,17 +37581,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: @@ -35574,46 +37591,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 172: + case 173: result = ts.reduceLeft(node.elements, f, result); break; - case 170: + case 174: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 171: + case 175: result = ts.reduceLeft(node.elements, f, result); break; - case 172: + case 176: result = ts.reduceLeft(node.properties, f, result); break; - case 173: + case 177: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174: + case 178: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175: + case 179: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176: + case 180: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177: + case 181: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180: + case 184: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35621,117 +37646,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181: + case 185: 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 189: + case 195: + case 196: + case 201: + result = reduceNode(node.expression, f, result); + break; + case 190: + case 191: result = reduceNode(node.operand, f, result); break; - case 188: + case 192: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189: + case 193: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190: + case 194: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193: + case 197: 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 199: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 198: + case 202: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 200: + case 204: result = ts.reduceLeft(node.statements, f, result); break; - case 201: + case 205: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203: + case 207: result = reduceNode(node.expression, f, result); break; - case 204: + case 208: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205: + case 209: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206: - case 213: + case 210: + case 217: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207: + case 211: 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 212: + case 213: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212: case 216: + case 220: result = reduceNode(node.expression, f, result); break; - case 214: + case 218: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215: + case 219: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217: + case 221: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219: + case 223: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220: + case 224: result = ts.reduceLeft(node.declarations, f, result); break; - case 221: + case 225: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35740,7 +37765,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222: + case 226: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35748,89 +37773,92 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228: + case 232: result = ts.reduceLeft(node.clauses, f, result); break; - case 231: + case 235: 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 236: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233: + case 237: result = reduceNode(node.name, f, result); break; - case 234: case 238: + case 242: result = ts.reduceLeft(node.elements, f, result); break; - case 235: case 239: + case 243: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236: + case 240: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237: + case 241: 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 246: 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 247: + case 248: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245: + case 249: result = reduceNode(node.tagName, f, result); break; - case 246: + case 250: 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); - 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); + break; + case 253: + result = reduceNode(node.expression, f, result); + case 254: + result = ts.reduceLeft(node.statements, f, result); + break; + case 255: + result = ts.reduceLeft(node.types, f, result); + break; + case 256: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; - case 253: + case 257: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254: + case 258: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; - case 256: + case 259: + result = reduceNode(node.expression, f, result); + break; + case 261: result = ts.reduceLeft(node.statements, f, result); break; - case 288: + case 293: result = reduceNode(node.expression, f, result); break; default: @@ -35855,6 +37883,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -35897,6 +37926,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) { @@ -35933,178 +37963,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 <= 171)) { 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 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())); + case 198: case 222: + 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 172: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 173: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 174: + 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 175: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 176: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 177: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 178: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 179: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 180: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 181: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 183: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 184: + 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 185: + 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 186: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 187: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 189: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 192: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 190: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 191: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 193: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 194: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 195: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 196: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 197: + 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 199: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 204: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 205: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 207: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 208: + 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 209: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 210: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 211: + 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 212: + 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 213: + 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 214: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 215: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 216: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 217: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 218: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 219: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 220: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 221: + 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 223: + 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 224: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 225: + 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 226: 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)); - case 234: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 235: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + 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 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.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); 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.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 238: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 239: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + case 240: + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 241: + 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 242: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); 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)); - case 245: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 246: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSelfClosingElement(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.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 250: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 251: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxSpreadAttribute(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.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), 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.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 255: + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 256: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 257: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 258: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 259: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 261: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 288: + case 293: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -36163,7 +38195,7 @@ var ts; return 0; } else if (node.transformFlags & 536870912) { - return node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); + return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind); } else { var subtreeFlags = aggregateTransformFlagsForSubtree(node); @@ -36179,68 +38211,17 @@ var ts; function aggregateTransformFlagsForChildNode(transformFlags, child) { return transformFlags | aggregateTransformFlagsForNode(child); } - function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 && kind <= 167) { - 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 150: - 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: - case 153: - case 154: - case 223: - case 224: - return -3; - case 172: - return 539110741; - default: - return 536874325; - } - } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function () { }; + : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function () { }; + : ts.noop; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function () { }; + : ts.noop; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36259,7 +38240,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)) { @@ -36278,7 +38259,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); } @@ -36296,11 +38277,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); @@ -36313,12 +38297,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) { @@ -36348,33 +38335,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); } @@ -36405,17 +38398,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172) { + if (target.kind === 176) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171) { + else if (target.kind === 175) { 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_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) { @@ -36423,16 +38416,79 @@ 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 === 257 || p.kind === 258) { + if (!transformRest || + p.transformFlags & 8388608 || + (p.kind === 257 && p.initializer.transformFlags & 8388608)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 258 ? p : p.initializer || propName; + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && + p.kind === 259 && + 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 === 198) { + 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) { @@ -36440,8 +38496,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 !== 198) { + if (e.kind !== 196) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36450,42 +38506,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 === 173) { + 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) { @@ -36528,12 +38672,6 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; - var TypeScriptSubstitutionFlags; - (function (TypeScriptSubstitutionFlags) { - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; - })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36544,14 +38682,14 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(174); + context.enableSubstitution(177); + context.enableSubstitution(178); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -36577,7 +38715,7 @@ var ts; return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 256) { + if (node.kind === 261) { return visitSourceFile(node); } else if (node.transformFlags & 1) { @@ -36593,13 +38731,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231: + case 235: return visitImportDeclaration(node); - case 230: + case 234: return visitImportEqualsDeclaration(node); - case 236: + case 240: return visitExportAssignment(node); - case 237: + case 241: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -36609,11 +38747,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 === 241 || + node.kind === 235 || + node.kind === 236 || + (node.kind === 234 && + node.moduleReference.kind === 245)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36629,21 +38767,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 203: 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); @@ -36658,78 +38805,81 @@ 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 171: + case 155: + case 145: + case 228: + 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 227: + return ts.createNotEmittedStatement(node); case 226: - return visitModuleDeclaration(node); + return visitClassDeclaration(node); + case 197: + return visitClassExpression(node); + case 255: + return visitHeritageClause(node); + case 199: + return visitExpressionWithTypeArguments(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessor(node); + case 152: + return visitSetAccessor(node); + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 183: + return visitParenthesizedExpression(node); + case 182: + case 200: + return visitAssertionExpression(node); + case 179: + return visitCallExpression(node); + case 180: + return visitNewExpression(node); + case 201: + return visitNonNullExpression(node); + case 229: + return visitEnumDeclaration(node); + case 205: + return visitVariableStatement(node); + case 223: + return visitVariableDeclaration(node); case 230: + return visitModuleDeclaration(node); + case 234: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36738,15 +38888,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 256: - case 228: - case 227: - case 200: + case 261: + case 232: + case 231: + case 204: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222: - case 221: + case 226: + case 225: if (ts.hasModifier(node, 2)) { break; } @@ -36756,10 +38906,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(); @@ -36770,10 +38921,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; } @@ -36800,66 +38951,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); @@ -36892,7 +39036,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); @@ -36934,7 +39078,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -36968,7 +39112,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; } @@ -37041,12 +39185,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; @@ -37124,37 +39268,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); @@ -37165,7 +39305,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); } @@ -37183,13 +39323,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))); } } } @@ -37197,58 +39337,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 === 226 + || kind === 197 + || 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 226: + case 197: + 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 { @@ -37296,20 +39436,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 171: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -37323,16 +39463,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; @@ -37356,10 +39496,13 @@ var ts; return serializedUnion; } } - case 159: case 160: + case 168: + case 169: + case 170: + case 161: case 118: - case 166: + case 167: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37401,15 +39544,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_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_27), ts.createLiteral("undefined")), name_27); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); } - return name_27; - case 140: + return name_33; + case 141: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -37483,7 +39626,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); @@ -37496,27 +39639,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]; @@ -37529,12 +39672,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; } @@ -37581,7 +39724,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)); @@ -37603,7 +39746,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); @@ -37639,39 +39782,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) { @@ -37706,9 +39842,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; @@ -37723,32 +39861,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_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 === 229) { + 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)) { @@ -37758,25 +39901,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) { @@ -37791,7 +39935,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227) { + if (body.kind === 231) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37814,13 +39958,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 227) { + if (body.kind !== 231) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226) { + if (moduleDeclaration.body.kind === 230) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -37840,7 +39984,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 233) { + if (node.kind === 237) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -37892,8 +40036,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 { @@ -37918,36 +40062,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); @@ -37957,40 +40085,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() { @@ -38010,15 +40119,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(254); - context.enableEmitNotification(226); + context.enableSubstitution(258); + context.enableEmitNotification(230); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226; + return ts.getOriginalNode(node).kind === 230; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 229; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38043,14 +40152,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_30 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_30); + 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_30, initializer, node); + return ts.createPropertyAssignment(name_35, initializer, node); } - return ts.createPropertyAssignment(name_30, exportedName, node); + return ts.createPropertyAssignment(name_35, exportedName, node); } } return node; @@ -38059,9 +40168,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 173: + case 177: return substitutePropertyAccessExpression(node); - case 174: + case 178: return substituteElementAccessExpression(node); } return node; @@ -38089,11 +40198,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 !== 261) { + var substitute = (applicableSubstitutions & 2 && container.kind === 230) || + (applicableSubstitutions & 8 && container.kind === 229); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38164,11 +40273,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242: + case 246: return visitJsxElement(node, false); - case 243: + case 247: return visitJsxSelfClosingElement(node, false); - case 248: + case 252: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38179,11 +40288,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 248: + case 252: return visitJsxExpression(node); - case 242: + case 246: return visitJsxElement(node, true); - case 243: + case 247: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38213,7 +40322,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); } @@ -38235,7 +40344,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 248) { + else if (node.kind === 252) { return visitJsxExpression(node); } else { @@ -38300,16 +40409,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242) { + if (node.kind === 246) { return getTagName(node.openingElement); } else { - var name_31 = node.tagName; - if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { - return ts.createLiteral(name_31.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_31); + return ts.createExpressionFromEntityName(name_36); } } } @@ -38586,12 +40695,165 @@ 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 176: + return visitObjectLiteralExpression(node); + case 192: + return visitBinaryExpression(node); + case 223: + return visitVariableDeclaration(node); + case 213: + return visitForOfStatement(node); + case 172: + case 173: + return node; + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + 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 === 259) { + 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 === 257) { + 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 !== 176) { + 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 === 172 && + !!(declaration.name.transformFlags & 8388608); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 176 && + 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 === 172 && + !!(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 ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); @@ -38614,10 +40876,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; @@ -38626,15 +40888,15 @@ var ts; switch (node.kind) { case 119: return undefined; - case 185: + case 189: return visitAwaitExpression(node); - case 148: + case 149: return visitMethodDeclaration(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); - case 181: + case 185: return visitArrowFunction(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38699,9 +40961,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 === 185; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; @@ -38744,12 +41007,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; @@ -38757,23 +41022,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(179); + context.enableSubstitution(177); + context.enableSubstitution(178); + context.enableEmitNotification(226); context.enableEmitNotification(149); + context.enableEmitNotification(151); + context.enableEmitNotification(152); + context.enableEmitNotification(150); } } function substituteExpression(node) { switch (node.kind) { - case 173: + case 177: return substitutePropertyAccessExpression(node); - case 174: + case 178: return substituteElementAccessExpression(node); - case 175: + case 179: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -38816,11 +41081,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 - || kind === 149 - || kind === 148 + return kind === 226 || kind === 150 - || kind === 151; + || kind === 149 + || kind === 151 + || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38866,10 +41131,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 { @@ -38878,7 +41143,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188: + case 192: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38921,28 +41186,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var ES2015SubstitutionFlags; - (function (ES2015SubstitutionFlags) { - ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -38960,6 +41203,7 @@ var ts; var enclosingFunction; var enclosingNonArrowFunction; var enclosingNonAsyncFunctionBody; + var isInConstructorWithCapturedSuper; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -38989,11 +41233,14 @@ var ts; var savedCurrentParent = currentParent; var savedCurrentNode = currentNode; var savedConvertedLoopState = convertedLoopState; + var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; if (ts.nodeStartsNewLexicalEnvironment(node)) { + isInConstructorWithCapturedSuper = false; convertedLoopState = undefined; } onBeforeVisitNode(node); var visited = f(node); + isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; convertedLoopState = savedConvertedLoopState; enclosingFunction = savedEnclosingFunction; enclosingNonArrowFunction = savedEnclosingNonArrowFunction; @@ -39005,16 +41252,25 @@ var ts; currentNode = savedCurrentNode; return visited; } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + } + function isReturnVoidStatementInConstructorWithCapturedSuper(node) { + return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + } function shouldCheckNode(node) { - return (node.transformFlags & 256) !== 0 || - node.kind === 215 || + return (node.transformFlags & 1024) !== 0 || + node.kind === 219 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { - if (shouldCheckNode(node)) { + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512) { + else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -39033,14 +41289,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212: + case 216: + node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201: + case 205: return visitVariableStatement(node); - case 214: + case 218: return visitSwitchStatement(node); - case 211: - case 210: + case 215: + case 214: return visitBreakOrContinueStatement(node); case 98: return visitThisKeyword(node); @@ -39052,74 +41309,76 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83: - return node; - case 222: + case 114: + return undefined; + case 226: return visitClassDeclaration(node); - case 193: + case 197: return visitClassExpression(node); - case 143: + case 144: return visitParameter(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 181: + case 185: return visitArrowFunction(node); - case 180: + case 184: return visitFunctionExpression(node); - case 219: + case 223: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 220: + case 224: return visitVariableDeclarationList(node); - case 215: + case 219: return visitLabeledStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); case 209: + return visitDoStatement(node); + case 210: + return visitWhileStatement(node); + case 211: + return visitForStatement(node); + case 212: + return visitForInStatement(node); + case 213: return visitForOfStatement(node); - case 203: + case 207: return visitExpressionStatement(node); - case 172: - return visitObjectLiteralExpression(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 171: - return visitArrayLiteralExpression(node); - case 175: - return visitCallExpression(node); case 176: - return visitNewExpression(node); + return visitObjectLiteralExpression(node); + case 256: + return visitCatchClause(node); + case 258: + return visitShorthandPropertyAssignment(node); + case 175: + return visitArrayLiteralExpression(node); case 179: + return visitCallExpression(node); + case 180: + return visitNewExpression(node); + case 183: return visitParenthesizedExpression(node, true); - case 188: + case 192: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 177: + case 181: return visitTaggedTemplateExpression(node); - case 190: + case 194: return visitTemplateExpression(node); - case 191: + case 195: return visitYieldExpression(node); case 96: return visitSuperKeyword(); - case 191: + case 195: return ts.visitEachChild(node, visitor, context); - case 148: + case 149: return visitMethodDeclaration(node); - case 256: + case 261: return visitSourceFileNode(node); - case 201: + case 205: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39134,7 +41393,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181) { + if (currentNode.kind !== 185) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39142,14 +41401,14 @@ var ts; } } switch (currentNode.kind) { - case 201: + case 205: enclosingVariableStatement = currentNode; break; - case 220: - case 219: - case 170: - case 168: - case 169: + case 224: + case 223: + case 174: + case 172: + case 173: break; default: enclosingVariableStatement = undefined; @@ -39177,7 +41436,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181) { + if (enclosingFunction && enclosingFunction.kind === 185) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39197,13 +41456,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 211 ? 2 : 4; + var jump = node.kind === 215 ? 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 === 215) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39213,7 +41472,7 @@ var ts; } } else { - if (node.kind === 211) { + if (node.kind === 215) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39243,26 +41502,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); @@ -39272,7 +41531,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); } @@ -39293,7 +41552,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); @@ -39308,13 +41567,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); } @@ -39337,8 +41596,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); @@ -39346,7 +41605,10 @@ var ts; statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); + var body = saveStateAndInvoke(constructor, function (constructor) { + isInConstructorWithCapturedSuper = superCaptureStatus === 1; + return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); + }); ts.addRange(statements, body); } if (extendsClauseElement @@ -39362,17 +41624,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 212) { + if (statement.kind === 216) { return true; } - else if (statement.kind === 204) { + else if (statement.kind === 208) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200) { + else if (statement.kind === 204) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39383,7 +41645,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0; } @@ -39392,7 +41654,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -39401,7 +41663,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 === 207 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39410,7 +41672,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; } @@ -39427,111 +41689,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_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_32)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_32, 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 203: 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); @@ -39596,7 +41780,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 262144) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39607,80 +41791,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 !== 185) { 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 183: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 188: + case 192: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39688,9 +41814,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 179: + case 183: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 188: + case 192: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39736,7 +41862,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); @@ -39755,8 +41881,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 - && enclosingBlockScopeContainer.kind !== 209 + && enclosingBlockScopeContainer.kind !== 212 + && enclosingBlockScopeContainer.kind !== 213 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39818,68 +41944,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; @@ -39887,8 +41952,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; } @@ -39943,11 +42008,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207: - case 208: - case 209: + case 211: + case 212: + case 213: var initializer = node.initializer; - if (initializer && initializer.kind === 220) { + if (initializer && initializer.kind === 224) { loopInitializer = initializer; } break; @@ -39986,7 +42051,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; @@ -39994,9 +42059,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) { @@ -40054,7 +42119,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 + statements.push(currentParent.kind === 219 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -40153,7 +42218,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 }); @@ -40166,20 +42231,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 257: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254: + case 258: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148: + case 149: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -40209,6 +42274,19 @@ var ts; } return expression; } + function visitCatchClause(node) { + ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + function addStatementToStartOfBlock(block, statement) { + var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); + return ts.updateBlock(block, [statement].concat(transformedStatements)); + } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); @@ -40236,7 +42314,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 { @@ -40253,35 +42331,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 !== 175 ? 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) { @@ -40354,7 +42432,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 175 + && currentParent.kind !== 179 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40363,7 +42441,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); @@ -40388,13 +42466,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(185); + context.enableEmitNotification(184); + context.enableEmitNotification(225); } } function onSubstituteNode(emitContext, node) { @@ -40419,10 +42497,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170: - case 222: - case 225: - case 219: + case 174: + case 226: + case 229: + case 223: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40454,28 +42532,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_33 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_33, emitFlags); - } - return name_33; - } - 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) { @@ -40487,11 +42545,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 !== 207) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { return false; } var callTarget = statementExpression.expression; @@ -40499,7 +42557,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 !== 196) { return false; } var expression = callArgument.expression; @@ -40510,51 +42568,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var OpCode; - (function (OpCode) { - OpCode[OpCode["Nop"] = 0] = "Nop"; - OpCode[OpCode["Statement"] = 1] = "Statement"; - OpCode[OpCode["Assign"] = 2] = "Assign"; - OpCode[OpCode["Break"] = 3] = "Break"; - OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; - OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; - OpCode[OpCode["Yield"] = 6] = "Yield"; - OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; - OpCode[OpCode["Return"] = 8] = "Return"; - OpCode[OpCode["Throw"] = 9] = "Throw"; - OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; - })(OpCode || (OpCode = {})); - var BlockAction; - (function (BlockAction) { - BlockAction[BlockAction["Open"] = 0] = "Open"; - BlockAction[BlockAction["Close"] = 1] = "Close"; - })(BlockAction || (BlockAction = {})); - var CodeBlockKind; - (function (CodeBlockKind) { - CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; - CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; - CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; - CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; - CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; - })(CodeBlockKind || (CodeBlockKind = {})); - var ExceptionBlockState; - (function (ExceptionBlockState) { - ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; - ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; - ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; - ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; - })(ExceptionBlockState || (ExceptionBlockState = {})); - var Instruction; - (function (Instruction) { - Instruction[Instruction["Next"] = 0] = "Next"; - Instruction[Instruction["Throw"] = 1] = "Throw"; - Instruction[Instruction["Return"] = 2] = "Return"; - Instruction[Instruction["Break"] = 3] = "Break"; - Instruction[Instruction["Yield"] = 4] = "Yield"; - Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; - Instruction[Instruction["Catch"] = 6] = "Catch"; - Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; - })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40600,7 +42613,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; @@ -40615,10 +42628,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 { @@ -40627,13 +42640,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205: + case 209: return visitDoStatement(node); - case 206: + case 210: return visitWhileStatement(node); - case 214: + case 218: return visitSwitchStatement(node); - case 215: + case 219: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40641,30 +42654,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); - case 150: case 151: + case 152: return visitAccessorDeclaration(node); - case 201: + case 205: return visitVariableStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); case 211: - return visitBreakStatement(node); - case 210: - return visitContinueStatement(node); + return visitForStatement(node); case 212: + return visitForInStatement(node); + case 215: + return visitBreakStatement(node); + case 214: + return visitContinueStatement(node); + case 216: 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 { @@ -40674,21 +42687,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188: + case 192: return visitBinaryExpression(node); - case 189: + case 193: return visitConditionalExpression(node); - case 191: + case 195: return visitYieldExpression(node); - case 171: - return visitArrayLiteralExpression(node); - case 172: - return visitObjectLiteralExpression(node); - case 174: - return visitElementAccessExpression(node); case 175: - return visitCallExpression(node); + return visitArrayLiteralExpression(node); case 176: + return visitObjectLiteralExpression(node); + case 178: + return visitElementAccessExpression(node); + case 179: + return visitCallExpression(node); + case 180: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40696,9 +42709,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40801,7 +42814,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; } @@ -40855,10 +42868,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173: + case 177: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174: + case 178: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -41050,35 +43063,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); - case 206: - return transformAndEmitWhileStatement(node); + return transformAndEmitBlock(node); case 207: - return transformAndEmitForStatement(node); + return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitForInStatement(node); + return transformAndEmitIfStatement(node); + case 209: + return transformAndEmitDoStatement(node); case 210: - return transformAndEmitContinueStatement(node); + return transformAndEmitWhileStatement(node); case 211: - return transformAndEmitBreakStatement(node); + return transformAndEmitForStatement(node); case 212: - return transformAndEmitReturnStatement(node); - case 213: - return transformAndEmitWithStatement(node); + return transformAndEmitForInStatement(node); case 214: - return transformAndEmitSwitchStatement(node); + return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitLabeledStatement(node); + return transformAndEmitBreakStatement(node); case 216: - return transformAndEmitThrowStatement(node); + return transformAndEmitReturnStatement(node); case 217: + return transformAndEmitWithStatement(node); + case 218: + return transformAndEmitSwitchStatement(node); + case 219: + return transformAndEmitLabeledStatement(node); + case 220: + return transformAndEmitThrowStatement(node); + case 221: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41362,7 +43375,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 === 254 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -41372,7 +43385,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 === 253) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -41463,7 +43476,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; @@ -41493,9 +43506,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_34) { - var clone_8 = ts.getMutableClone(name_34); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_8 = ts.getMutableClone(name_37); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -41794,7 +43807,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -41803,7 +43816,7 @@ var ts; } return expression; } - return ts.createNode(194); + return ts.createOmittedExpression(); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41891,7 +43904,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() { @@ -42162,8 +44175,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(253); + context.enableSubstitution(177); + context.enableSubstitution(257); return transformSourceFile; function transformSourceFile(node) { return node; @@ -42222,48 +44235,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(192); + context.enableSubstitution(190); + context.enableSubstitution(191); + context.enableSubstitution(258); + context.enableEmitNotification(261); + 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; @@ -42280,77 +44285,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 235: return visitImportDeclaration(node); - case 230: + case 234: return visitImportEqualsDeclaration(node); - case 237: + case 241: return visitExportDeclaration(node); - case 236: + case 240: return visitExportAssignment(node); - case 201: + case 205: return visitVariableStatement(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 222: + case 226: return visitClassDeclaration(node); - case 203: - return visitExpressionStatement(node); + case 294: + return visitMergeDeclarationMarker(node); + case 295: + 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 = []; @@ -42363,43 +44396,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); @@ -42413,7 +44463,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); } @@ -42429,195 +44479,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_35 = names_1[_i]; - addExportMemberAssignments(statements, name_35); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_36 = node.name; - if (ts.isIdentifier(name_36)) { - names.push(name_36); - } - } - 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 === 205) { + 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 237: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238: + 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 === 261) { + 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); @@ -42625,6 +44728,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); } @@ -42649,141 +44755,82 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 188: + case 192: return substituteBinaryExpression(node); - case 187: - case 186: + case 191: + case 190: 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 === 261) { + 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 === 191 + ? 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_37 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), 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; } @@ -42792,7 +44839,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(); @@ -42801,696 +44848,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(192); + context.enableSubstitution(190); + context.enableSubstitution(191); + context.enableEmitNotification(261); + 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_38 = node.name || ts.getGeneratedNameForNode(node); - var isAsync = ts.hasModifier(node, 256); - var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_38); - } - 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_39 = getDeclarationName(originalNode); - if (originalNode.kind === 225) { - hoistVariableDeclaration(name_39); - } - return [ - node, - createExportStatement(name_39, name_39) - ]; - } - 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(); @@ -43502,7 +44911,6 @@ var ts; if (ts.hasProperty(groupIndices, text)) { var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; } else { groupIndices[text] = dependencyGroups.length; @@ -43514,47 +44922,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 === 241 && 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 !== 241) { + 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 235: + if (!entry.importClause) { + break; + } + case 234: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 241: + 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 235: + return visitImportDeclaration(node); + case 234: + return visitImportEqualsDeclaration(node); + case 241: + return undefined; + case 240: + 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 === 261 + || (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 === 205) { + 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 237: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238: + 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 205: + return visitVariableStatement(node); + case 225: + return visitFunctionDeclaration(node); + case 226: + return visitClassDeclaration(node); + case 211: + return visitForStatement(node); + case 212: + return visitForInStatement(node); + case 213: + return visitForOfStatement(node); + case 209: + return visitDoStatement(node); + case 210: + return visitWhileStatement(node); + case 219: + return visitLabeledStatement(node); + case 217: + return visitWithStatement(node); + case 218: + return visitSwitchStatement(node); + case 232: + return visitCaseBlock(node); + case 253: + return visitCaseClause(node); + case 254: + return visitDefaultClause(node); + case 221: + return visitTryStatement(node); + case 256: + return visitCatchClause(node); + case 204: + return visitBlock(node); + case 294: + return visitMergeDeclarationMarker(node); + case 295: + 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 === 192) { + 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 === 261; + } + 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 === 261) { + 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 192: + return substituteBinaryExpression(node); + case 190: + case 191: + 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 === 191 + ? 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 === 191) { + 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 === 261) { + 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; @@ -43575,9 +45658,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 234: return undefined; - case 236: + case 240: return visitExportAssignment(node); } return node; @@ -43598,21 +45681,18 @@ var ts; _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); - var SyntaxKindFeatureFlags; - (function (SyntaxKindFeatureFlags) { - SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; - SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; - })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); 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); } @@ -43623,6 +45703,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); } @@ -43632,7 +45713,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289); + var enabledSyntaxKindFeatures = new Array(296); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -43785,7 +45866,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? ts.noop : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -43829,7 +45910,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 === 235); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43900,10 +45981,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219) { + if (declaration.kind === 223) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { + else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43914,7 +45995,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 === 235) { moduleElementEmitInfo.isVisible = true; } else { @@ -43922,12 +46003,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 230) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 230) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -44040,43 +46121,49 @@ 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 171: return writeTextOfNode(currentText, type); - case 195: + case 199: 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 emitIndexedAccessType(type); + case 170: + return emitMappedType(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) { @@ -44084,22 +46171,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 === 234 ? 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 === 177); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44145,6 +46232,42 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitIndexedAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } + function emitMappedType(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + writeEntityName(node.typeParameter.name); + write(" in "); + emitType(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emitType(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + enclosingDeclaration = prevEnclosingDeclaration; + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -44173,9 +46296,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -44219,10 +46342,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 || - (node.parent.kind === 256 && isCurrentFileExternalModule)) { + else if (node.kind === 234 || + (node.parent.kind === 261 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -44231,7 +46354,7 @@ var ts; }); } else { - if (node.kind === 231) { + if (node.kind === 235) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44249,30 +46372,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 205: + return writeVariableStatement(node); + case 227: + return writeInterfaceDeclaration(node); case 226: - return writeModuleDeclaration(node); + return writeClassDeclaration(node); + case 228: + return writeTypeAliasDeclaration(node); + case 229: + return writeEnumDeclaration(node); case 230: + return writeModuleDeclaration(node); + case 234: return writeImportEqualsDeclaration(node); - case 231: + case 235: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 256) { + if (node.parent.kind === 261) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -44280,7 +46403,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 223 && !noDeclare) { + else if (node.kind !== 227 && !noDeclare) { write("declare "); } } @@ -44330,7 +46453,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 237) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44353,7 +46476,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 233) { + if (node.importClause.namedBindings.kind === 237) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44370,13 +46493,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; var moduleSpecifier; - if (parent.kind === 230) { + if (parent.kind === 234) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226) { + else if (parent.kind === 230) { moduleSpecifier = parent.name; } else { @@ -44444,7 +46567,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227) { + while (node.body && node.body.kind !== 231) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44514,7 +46637,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) { @@ -44524,15 +46647,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 { @@ -44542,31 +46665,31 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 222: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223: + case 227: 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 === 226) { 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 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44603,7 +46726,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 226) { 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; @@ -44683,17 +46806,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 223 || 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)) { @@ -44706,14 +46829,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219) { + if (node.kind === 223) { 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 ? @@ -44721,7 +46844,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 === 226) { 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 : @@ -44747,7 +46870,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 !== 198) { elements.push(element); } } @@ -44813,7 +46936,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; @@ -44826,7 +46949,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 @@ -44835,7 +46958,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 : @@ -44881,17 +47004,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221) { + if (node.kind === 225) { 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 === 225) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149) { + else if (node.kind === 150) { write("constructor"); } else { @@ -44911,15 +47034,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; @@ -44930,20 +47053,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; @@ -44957,23 +47080,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 ? @@ -44981,7 +47104,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 === 226) { 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 : @@ -44994,7 +47117,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221: + case 225: 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 : @@ -45026,9 +47149,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)) { @@ -45044,22 +47167,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 ? @@ -45067,7 +47190,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 === 226) { 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 : @@ -45079,7 +47202,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 225: 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 : @@ -45090,12 +47213,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 172) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 173) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -45106,10 +47229,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194) { + if (bindingElement.kind === 198) { write(" "); } - else if (bindingElement.kind === 170) { + else if (bindingElement.kind === 174) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45131,39 +47254,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221: - case 226: - case 230: - case 223: - case 222: - case 224: case 225: + case 230: + case 234: + case 227: + case 226: + case 228: + case 229: return emitModuleElement(node, isModuleElementVisible(node)); - case 201: + case 205: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231: + case 235: return emitModuleElement(node, !node.importClause); - case 237: + case 241: 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 260: return emitEnumMemberDeclaration(node); - case 236: + case 240: return emitExportAssignment(node); - case 256: + case 261: return emitSourceFile(node); } } @@ -45380,7 +47503,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 !== 292 && (emitFlags & 512) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -45393,7 +47516,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 + if (node.kind !== 292 && (emitFlags & 1024) === 0 && end >= 0) { emitPos(end); @@ -45537,7 +47660,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287; + var isEmittedNode = node.kind !== 292; var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -45551,7 +47674,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 220) { + if (node.kind === 224) { declarationListContainerEnd = end; } } @@ -45751,12 +47874,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { @@ -45764,6 +47881,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};"; @@ -45796,6 +47914,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -45929,7 +48048,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 256: + case 261: return emitSourceFile(node); } } @@ -45967,7 +48086,6 @@ var ts; case 123: case 124: case 125: - case 126: case 127: case 128: case 129: @@ -45981,182 +48099,191 @@ 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); - case 198: - return emitTemplateSpan(node); + return emitParenthesizedType(node); case 199: - return emitSemicolonClassElement(); - case 200: - return emitBlock(node); - case 201: - return emitVariableStatement(node); + return emitExpressionWithTypeArguments(node); + case 167: + return emitThisType(); + case 168: + return emitTypeOperator(node); + case 169: + return emitIndexedAccessType(node); + case 170: + return emitMappedType(node); + case 171: + return emitLiteralType(node); + case 172: + return emitObjectBindingPattern(node); + case 173: + return emitArrayBindingPattern(node); + case 174: + return emitBindingElement(node); case 202: - return emitEmptyStatement(); + return emitTemplateSpan(node); case 203: - return emitExpressionStatement(node); + return emitSemicolonClassElement(); case 204: - return emitIfStatement(node); + return emitBlock(node); case 205: - return emitDoStatement(node); + return emitVariableStatement(node); case 206: - return emitWhileStatement(node); + return emitEmptyStatement(); case 207: - return emitForStatement(node); + return emitExpressionStatement(node); case 208: - return emitForInStatement(node); + return emitIfStatement(node); case 209: - return emitForOfStatement(node); + return emitDoStatement(node); case 210: - return emitContinueStatement(node); + return emitWhileStatement(node); case 211: - return emitBreakStatement(node); + return emitForStatement(node); case 212: - return emitReturnStatement(node); + return emitForInStatement(node); case 213: - return emitWithStatement(node); + return emitForOfStatement(node); case 214: - return emitSwitchStatement(node); + return emitContinueStatement(node); case 215: - return emitLabeledStatement(node); + return emitBreakStatement(node); case 216: - return emitThrowStatement(node); + return emitReturnStatement(node); case 217: - return emitTryStatement(node); + return emitWithStatement(node); case 218: - return emitDebuggerStatement(node); + return emitSwitchStatement(node); case 219: - return emitVariableDeclaration(node); + return emitLabeledStatement(node); case 220: - return emitVariableDeclarationList(node); + return emitThrowStatement(node); case 221: - return emitFunctionDeclaration(node); + return emitTryStatement(node); case 222: - return emitClassDeclaration(node); + return emitDebuggerStatement(node); case 223: - return emitInterfaceDeclaration(node); + return emitVariableDeclaration(node); case 224: - return emitTypeAliasDeclaration(node); + return emitVariableDeclarationList(node); case 225: - return emitEnumDeclaration(node); + return emitFunctionDeclaration(node); case 226: - return emitModuleDeclaration(node); + return emitClassDeclaration(node); case 227: - return emitModuleBlock(node); + return emitInterfaceDeclaration(node); case 228: - return emitCaseBlock(node); + return emitTypeAliasDeclaration(node); + case 229: + return emitEnumDeclaration(node); case 230: - return emitImportEqualsDeclaration(node); + return emitModuleDeclaration(node); case 231: - return emitImportDeclaration(node); + return emitModuleBlock(node); case 232: - return emitImportClause(node); - case 233: - return emitNamespaceImport(node); + return emitCaseBlock(node); case 234: - return emitNamedImports(node); + return emitImportEqualsDeclaration(node); case 235: - return emitImportSpecifier(node); + return emitImportDeclaration(node); case 236: - return emitExportAssignment(node); + return emitImportClause(node); case 237: - return emitExportDeclaration(node); + return emitNamespaceImport(node); case 238: - return emitNamedExports(node); + return emitNamedImports(node); case 239: - return emitExportSpecifier(node); + return emitImportSpecifier(node); case 240: - return; + return emitExportAssignment(node); case 241: + return emitExportDeclaration(node); + case 242: + return emitNamedExports(node); + case 243: + return emitExportSpecifier(node); + case 244: + return; + case 245: 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); case 248: - return emitJsxExpression(node); + return emitJsxOpeningElement(node); case 249: - return emitCaseClause(node); + return emitJsxClosingElement(node); case 250: - return emitDefaultClause(node); + return emitJsxAttribute(node); case 251: - return emitHeritageClause(node); + return emitJsxSpreadAttribute(node); case 252: - return emitCatchClause(node); + return emitJsxExpression(node); case 253: - return emitPropertyAssignment(node); + return emitCaseClause(node); case 254: - return emitShorthandPropertyAssignment(node); + return emitDefaultClause(node); case 255: + return emitHeritageClause(node); + case 256: + return emitCatchClause(node); + case 257: + return emitPropertyAssignment(node); + case 258: + return emitShorthandPropertyAssignment(node); + case 259: + return emitSpreadAssignment(node); + case 260: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -46181,63 +48308,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); case 175: - return emitCallExpression(node); + return emitArrayLiteralExpression(node); case 176: - return emitNewExpression(node); + return emitObjectLiteralExpression(node); case 177: - return emitTaggedTemplateExpression(node); + return emitPropertyAccessExpression(node); case 178: - return emitTypeAssertionExpression(node); + return emitElementAccessExpression(node); case 179: - return emitParenthesizedExpression(node); + return emitCallExpression(node); case 180: - return emitFunctionExpression(node); + return emitNewExpression(node); case 181: - return emitArrowFunction(node); + return emitTaggedTemplateExpression(node); case 182: - return emitDeleteExpression(node); + return emitTypeAssertionExpression(node); case 183: - return emitTypeOfExpression(node); + return emitParenthesizedExpression(node); case 184: - return emitVoidExpression(node); + return emitFunctionExpression(node); case 185: - return emitAwaitExpression(node); + return emitArrowFunction(node); case 186: - return emitPrefixUnaryExpression(node); + return emitDeleteExpression(node); case 187: - return emitPostfixUnaryExpression(node); + return emitTypeOfExpression(node); case 188: - return emitBinaryExpression(node); + return emitVoidExpression(node); case 189: - return emitConditionalExpression(node); + return emitAwaitExpression(node); case 190: - return emitTemplateExpression(node); + return emitPrefixUnaryExpression(node); case 191: - return emitYieldExpression(node); + return emitPostfixUnaryExpression(node); case 192: - return emitSpreadElementExpression(node); + return emitBinaryExpression(node); case 193: - return emitClassExpression(node); + return emitConditionalExpression(node); case 194: - return; + return emitTemplateExpression(node); + case 195: + return emitYieldExpression(node); case 196: - return emitAsExpression(node); + return emitSpreadExpression(node); case 197: + return emitClassExpression(node); + case 198: + return; + case 200: + return emitAsExpression(node); + case 201: return emitNonNullExpression(node); - case 242: + case 246: return emitJsxElement(node); - case 243: + case 247: return emitJsxSelfClosingElement(node); - case 288: + case 293: return emitPartiallyEmittedExpression(node); } } @@ -46341,7 +48468,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); } @@ -46426,6 +48553,39 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitIndexedAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } + function emitMappedType(node) { + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + emit(node.typeParameter.name); + write(" in "); + emit(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emit(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -46589,7 +48749,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 186 + return operand.kind === 190 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -46633,7 +48793,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -46701,7 +48861,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 204) { + if (node.elseStatement.kind === 208) { write(" "); emit(node.elseStatement); } @@ -46763,7 +48923,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220) { + if (node.kind === 224) { emit(node); } else { @@ -46992,7 +49152,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226) { + while (body.kind === 230) { write("."); emit(body.name); body = body.body; @@ -47211,6 +49371,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); @@ -47280,10 +49446,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) { @@ -47606,7 +49779,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 && ts.nodeIsSynthesized(node)) { + while (node.kind === 183 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -47663,21 +49836,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_40 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_41; + return name_40; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -47715,17 +49888,17 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 226: - case 225: + case 230: + case 229: return generateNameForModuleOrEnum(node); - case 231: - case 237: + case 235: + case 241: return generateNameForImportOrExportDeclaration(node); - case 221: - case 222: - case 236: + case 225: + case 226: + case 240: return generateNameForExportDefault(); - case 193: + case 197: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -47795,72 +49968,10 @@ var ts; } } ts.emitFiles = emitFiles; - var ListFormat; - (function (ListFormat) { - ListFormat[ListFormat["None"] = 0] = "None"; - ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; - ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; - ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; - ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; - ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; - ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; - ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; - ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; - ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; - ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; - })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.0"; + ts.version = "2.2.0"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -48075,11 +50186,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_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; @@ -48093,7 +50204,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(); @@ -48106,7 +50217,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; }; @@ -48168,6 +50286,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -48175,12 +50294,13 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); return program; function getCommonSourceDirectory() { - if (typeof commonSourceDirectory === "undefined") { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + if (commonSourceDirectory === undefined) { + var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } else { - commonSourceDirectory = computeCommonSourceDirectory(files); + commonSourceDirectory = computeCommonSourceDirectory(emittedFiles); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { commonSourceDirectory += ts.directorySeparator; @@ -48199,26 +50319,85 @@ 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; } var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.moduleResolution !== options.moduleResolution) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx) || - (oldOptions.allowJs !== options.allowJs) || - (oldOptions.rootDir !== options.rootDir) || - (oldOptions.configFilePath !== options.configFilePath) || - (oldOptions.baseUrl !== options.baseUrl) || - (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || - !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || - !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || - !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !ts.equalOwnProperties(oldOptions.paths, options.paths)) { + if (ts.changesAffectModuleResolution(oldOptions, options)) { return false; } ts.Debug.assert(!oldProgram.structureIsReused); @@ -48259,40 +50438,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; @@ -48308,11 +50491,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)); } @@ -48389,6 +50575,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) { @@ -48408,183 +50600,170 @@ 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 181: - case 221: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + case 152: + case 184: + case 225: + case 185: + case 225: + case 223: + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } + } + switch (node.kind) { + case 234: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 240: + if (node.isExportEquals) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; } break; - case 201: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; + case 255: + 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 219: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; + case 227: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 230: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 228: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 229: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 182: + 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 226: + case 149: + case 148: + case 150: + case 151: + case 152: + case 184: + case 225: + case 185: + case 225: + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + case 205: + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 205); } 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 179: + case 180: + case 199: + 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); } }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -48601,9 +50780,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); } @@ -48622,14 +50798,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(235); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -48641,12 +50821,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 235: + case 234: + case 241: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -48658,13 +50839,16 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226: + case 230: 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++) { @@ -48688,7 +50872,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("', '") + "'"]; @@ -48749,7 +50933,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); } @@ -48821,9 +51005,11 @@ var ts; } else { if (previousResolution) { - var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); - if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { + var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); + if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + } } saveResolution = false; } @@ -48858,23 +51044,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--; @@ -48884,7 +51078,6 @@ var ts; else { file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -49038,7 +51231,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) { @@ -49053,10 +51254,15 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + 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)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); } else { emitFilesSeen.set(emitFilePath, true); @@ -49064,1096 +51270,33 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, message) { + function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + programDiagnostics.add(diag); } } ts.createProgram = createProgram; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message, - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, - }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2, - "es2016": 3, - "es2017": 4, - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.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" - }), - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } - ]; - ts.typingOptionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean", - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" - } - } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false, - }; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - var key = trimString((value || "")).toLowerCase(); - var map = opt.type; - if (key in map) { - return map[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; - } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); - } - } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); - } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } - } - return undefined; + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } - 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) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_44] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_44] = convertedValue; - } - else { - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } - } - } - return result; + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; } } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; - } - } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typingOptions: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; - } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = ts.assign({}, baseOptions, options); - } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typingOptions: typingOptions, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; - } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } - else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); - } - } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; - } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; - } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); - return options; - } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; - } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); - } - } - } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); - } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); - } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - } - return value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); - } - } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); - } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; - } - } - } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; - } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; - } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - 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)) { - continue; - } - var match = wildcardDirectoryPattern.exec(name_45); - if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_45) ? 1 : 0; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } - } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } - } - } - return wildcardDirectories; - } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { - return true; - } - } - return false; - } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } - } - function addFileToOutput(output, file) { - output.push(file); - return output; - } - function caseSensitiveKeyMapper(key) { - return key; - } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); - } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; (function (ts) { @@ -50192,12 +51335,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"; @@ -50221,24 +51365,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; - (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; - (function (EndOfLineState) { - EndOfLineState[EndOfLineState["None"] = 0] = "None"; - EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; - EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; - EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; - EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; + })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -50249,8 +51377,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 = ""; @@ -50326,75 +51453,40 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; - (function (ClassificationType) { - ClassificationType[ClassificationType["comment"] = 1] = "comment"; - ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; - ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; - ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; - ClassificationType[ClassificationType["operator"] = 5] = "operator"; - ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; - ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; - ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; - ClassificationType[ClassificationType["text"] = 9] = "text"; - ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; - ClassificationType[ClassificationType["className"] = 11] = "className"; - ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; - ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; - ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; - ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; - ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; - ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; - ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; - ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; - ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; - ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; - ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; - ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; - ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(4, true); + ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; - (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; 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 223: + case 174: case 147: + case 146: + case 257: + case 258: + case 260: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 252: - return 1; - case 142: - case 223: - case 224: - case 160: - return 2; - case 222: + case 152: case 225: - return 1 | 2; + case 184: + case 185: + case 256: + return 1; + case 143: + case 227: + case 228: + case 161: + return 2; case 226: + case 229: + return 1 | 2; + case 230: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -50404,21 +51496,21 @@ var ts; else { return 4; } + case 238: + case 239: case 234: case 235: - case 230: - case 231: - case 236: - case 237: + case 240: + case 241: return 1 | 2 | 4; - case 256: + case 261: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 236) { + if (node.parent.kind === 240) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -50440,15 +51532,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 === 234) { 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; @@ -50459,27 +51551,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 === 177) { + while (root.parent && root.parent.kind === 177) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { 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 === 226 && root.parent.parent.token === 107) || + (decl.kind === 227 && root.parent.parent.token === 84); } return false; } @@ -50487,17 +51579,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 === 199 && !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, 179); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176); + return isCallOrNewExpressionTarget(node, 180); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -50510,7 +51602,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -50520,13 +51612,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 211 || node.parent.kind === 210) && + (node.parent.kind === 215 || node.parent.kind === 214) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 215 && + node.parent.kind === 219 && node.parent.label === node; } function isLabelName(node) { @@ -50534,15 +51626,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 === 177 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 226 && node.parent.name === node; + return node.parent.kind === 230 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -50553,19 +51645,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 257: + case 260: + case 149: + case 148: case 151: - case 226: + case 152: + case 230: return node.parent.name === node; - case 174: + case 178: return node.parent.argumentExpression === node; - case 141: + case 142: return true; } } @@ -50609,17 +51701,17 @@ var ts; return undefined; } switch (node.kind) { - case 256: + case 261: + case 149: case 148: - case 147: - case 221: - case 180: - case 150: - case 151: - case 222: - case 223: case 225: + case 184: + case 151: + case 152: case 226: + case 227: + case 229: + case 230: return node; } } @@ -50627,46 +51719,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256: + case 261: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226: - return ts.ScriptElementKind.moduleElement; - case 222: - case 193: - return ts.ScriptElementKind.classElement; - case 223: return ts.ScriptElementKind.interfaceElement; - case 224: return ts.ScriptElementKind.typeElement; - case 225: return ts.ScriptElementKind.enumElement; - case 219: - return getKindOfVariableDeclaration(node); - case 170: - return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181: - case 221: - case 180: - return ts.ScriptElementKind.functionElement; - case 150: return ts.ScriptElementKind.memberGetAccessorElement; - case 151: return ts.ScriptElementKind.memberSetAccessorElement; - case 148: - case 147: - return ts.ScriptElementKind.memberFunctionElement; - 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: + return ts.ScriptElementKind.moduleElement; + case 226: + case 197: + return ts.ScriptElementKind.classElement; + case 227: return ts.ScriptElementKind.interfaceElement; + case 228: return ts.ScriptElementKind.typeElement; + case 229: return ts.ScriptElementKind.enumElement; + case 223: + return getKindOfVariableDeclaration(node); + case 174: + return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 185: + case 225: + case 184: + return ts.ScriptElementKind.functionElement; + case 151: return ts.ScriptElementKind.memberGetAccessorElement; + case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 149: + case 148: + return ts.ScriptElementKind.memberFunctionElement; + case 147: + case 146: + return ts.ScriptElementKind.memberVariableElement; + 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 260: return ts.ScriptElementKind.enumMemberElement; + case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 234: case 239: - case 233: + case 236: + case 243: + case 237: return ts.ScriptElementKind.alias; - case 279: + case 284: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -50681,7 +51773,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 167 ? node.parent : node; + var searchNode = node.parent.kind === 171 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -50694,7 +51786,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; } @@ -50738,41 +51830,41 @@ var ts; return false; } switch (n.kind) { - case 222: - case 223: - case 225: - case 172: - case 168: - case 160: - case 200: + case 226: case 227: - case 228: - case 234: - case 238: - return nodeEndsWith(n, 17, sourceFile); - case 252: - return isCompletedNode(n.block, sourceFile); + case 229: case 176: + case 172: + case 161: + case 204: + case 231: + case 232: + case 238: + case 242: + return nodeEndsWith(n, 17, sourceFile); + case 256: + return isCompletedNode(n.block, sourceFile); + case 180: if (!n.arguments) { return true; } - case 175: case 179: - case 165: + case 183: + 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 225: + case 184: + case 149: + case 148: + case 154: + case 153: + case 185: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -50780,65 +51872,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 226: + case 230: return n.body && isCompletedNode(n.body, sourceFile); - case 204: + case 208: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203: + case 207: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 171: - case 169: - case 174: - case 141: - case 162: + case 175: + case 173: + case 178: + 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 253: + case 254: return false; - case 207: - case 208: - case 209: - case 206: + case 211: + case 212: + case 213: + case 210: return isCompletedNode(n.statement, sourceFile); - case 205: + case 209: 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 187: + case 186: + case 188: + case 195: + case 196: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177: + case 181: return isCompletedNode(n.template, sourceFile); - case 190: + case 194: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198: + case 202: return ts.nodeIsPresent(n.literal); - case 237: - case 231: + case 241: + case 235: return ts.nodeIsPresent(n.moduleSpecifier); - case 186: + case 190: return isCompletedNode(n.operand, sourceFile); - case 188: + case 192: return isCompletedNode(n.right, sourceFile); - case 189: + case 193: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -50881,7 +51973,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 === 291 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -51016,7 +52108,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256); + ts.Debug.assert(startNode !== undefined || n.kind === 261); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -51061,13 +52153,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 248) { + if (token.kind === 26 && token.parent.kind === 252) { return true; } - if (token && token.kind === 17 && token.parent.kind === 248) { + if (token && token.kind === 17 && token.parent.kind === 252) { return true; } - if (token.kind === 26 && token.parent.kind === 245) { + if (token.kind === 26 && token.parent.kind === 249) { return true; } return false; @@ -51158,17 +52250,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 156 || node.kind === 175) { + if (node.kind === 157 || node.kind === 179) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { + if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { 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) { @@ -51227,18 +52319,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 || - node.kind === 172) { - if (node.parent.kind === 188 && + if (node.kind === 175 || + node.kind === 176) { + if (node.parent.kind === 192 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 209 && + if (node.parent.kind === 213 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { return true; } } @@ -51269,7 +52361,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(); @@ -51291,8 +52383,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; function writeIndent() { if (lineStart) { @@ -51444,7 +52536,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); @@ -51454,7 +52546,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 235 || location.parent.kind === 239) && + (location.parent.kind === 239 || location.parent.kind === 243) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -51559,89 +52651,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201: + case 205: 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 223: case 147: - case 150: - case 151: + case 146: + return spanInVariableDeclaration(node); + case 144: + return spanInParameterDeclaration(node); + case 225: case 149: - case 180: - case 181: + case 148: + case 151: + case 152: + case 150: + case 184: + case 185: return spanInFunctionDeclaration(node); - case 200: + case 204: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 227: + case 231: return spanInBlock(node); - case 252: + case 256: 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 textSpan(node.expression); + case 216: + return textSpan(node.getChildAt(0), node.expression); + case 210: return textSpanEndingAtNextToken(node, node.expression); case 209: - return spanInInitializerOfForLike(node); - case 214: + return spanInNode(node.statement); + case 222: + return textSpan(node.getChildAt(0)); + case 208: return textSpanEndingAtNextToken(node, node.expression); - case 249: - case 250: + case 219: + return spanInNode(node.statement); + case 215: + case 214: + return textSpan(node.getChildAt(0), node.label); + case 211: + return spanInForStatement(node); + case 212: + return textSpanEndingAtNextToken(node, node.expression); + case 213: + return spanInInitializerOfForLike(node); + case 218: + return textSpanEndingAtNextToken(node, node.expression); + case 253: + case 254: return spanInNode(node.statements[0]); - case 217: + case 221: return spanInBlock(node.tryBlock); - case 216: + case 220: return textSpan(node, node.expression); - case 236: + case 240: return textSpan(node, node.expression); - case 230: + case 234: return textSpan(node, node.moduleReference); - case 231: + case 235: return textSpan(node, node.moduleSpecifier); - case 237: + case 241: return textSpan(node, node.moduleSpecifier); - case 226: + case 230: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 222: - case 225: - case 255: - case 170: + case 226: + case 229: + case 260: + case 174: return textSpan(node); - case 213: + case 217: return spanInNode(node.statement); - case 144: + case 145: return spanInNodeArray(node.parent.decorators); - case 168: - case 169: + case 172: + case 173: return spanInBindingPattern(node); - case 223: - case 224: + case 227: + case 228: return undefined; case 24: case 1: @@ -51669,20 +52761,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 == 196 || + node.kind === 257 || + node.kind === 258) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188) { + if (node.kind === 192) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -51697,38 +52789,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205: - return spanInPreviousNode(node); - case 144: - return spanInNode(node.parent); - case 207: case 209: + return spanInPreviousNode(node); + case 145: + return spanInNode(node.parent); + case 211: + case 213: return textSpan(node); - case 188: + case 192: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 181: + case 185: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 253 && + if (node.parent.kind === 257 && 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 === 182 && 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 === 223 || + node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -51736,7 +52828,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188) { + if (node.parent.kind === 192) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -51757,7 +52849,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 208) { + if (variableDeclaration.parent.parent.kind === 212) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -51765,7 +52857,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 209) { + variableDeclaration.parent.parent.kind === 213) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -51797,7 +52889,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); + (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -51817,22 +52909,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226: + case 230: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 206: - case 204: + case 210: case 208: + case 212: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 207: - case 209: + case 211: + case 213: 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 === 224) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -51854,62 +52946,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 !== 198 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 170) { + if (bindingPattern.parent.kind === 174) { 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 !== 173 && node.kind !== 172); + var elements = node.kind === 175 ? 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 !== 198 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 188 ? node.parent : node); + return textSpan(node.parent.kind === 192 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225: + case 229: 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 226: 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 232: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227: + case 231: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 225: - case 222: + case 229: + case 226: return textSpan(node); - case 200: + case 204: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 252: + case 256: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228: + case 232: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168: + case 172: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51922,7 +53014,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169: + case 173: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51934,33 +53026,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 205 || - node.parent.kind === 175 || - node.parent.kind === 176) { + if (node.parent.kind === 209 || + node.parent.kind === 179 || + node.parent.kind === 180) { return spanInPreviousNode(node); } - if (node.parent.kind === 179) { + if (node.parent.kind === 183) { 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 184: + case 225: + case 185: case 149: - case 206: - case 205: - case 207: + case 148: + case 151: + case 152: + case 150: + case 210: case 209: - case 175: - case 176: + case 211: + case 213: case 179: + case 180: + case 183: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -51968,26 +53060,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 || - node.parent.kind === 143) { + node.parent.kind === 257 || + node.parent.kind === 144) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 178) { + if (node.parent.kind === 182) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205) { + if (node.parent.kind === 209) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 213) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -52000,7 +53092,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; @@ -52018,7 +53110,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 132 || + keyword2 === 133 || keyword2 === 122 || keyword2 === 114) { return true; @@ -52134,10 +53226,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; } @@ -52292,7 +53384,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 139; + return token >= 71 && token <= 140; } function classFromKind(token) { if (isKeyword(token)) { @@ -52338,10 +53430,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { + case 230: case 226: - case 222: - case 223: - case 221: + case 227: + case 225: cancellationToken.throwIfCancellationRequested(); } } @@ -52385,7 +53477,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 && + return declaration.kind === 230 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -52457,8 +53549,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 }; @@ -52526,16 +53618,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 275: + case 280: processJSDocParameterTag(tag); break; - case 278: + case 283: processJSDocTemplateTag(tag); break; - case 277: + case 282: processElement(tag.typeExpression); break; - case 276: + case 281: processElement(tag.typeExpression); break; } @@ -52616,22 +53708,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244: + case 248: if (token.parent.tagName === token) { return 19; } break; - case 245: + case 249: if (token.parent.tagName === token) { return 20; } break; - case 243: + case 247: if (token.parent.tagName === token) { return 21; } break; - case 246: + case 250: if (token.parent.name === token) { return 22; } @@ -52651,17 +53743,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 === 223 || + token.parent.kind === 147 || + token.parent.kind === 144 || + token.parent.kind === 250) { return 5; } } - if (token.parent.kind === 188 || - token.parent.kind === 186 || - token.parent.kind === 187 || - token.parent.kind === 189) { + if (token.parent.kind === 192 || + token.parent.kind === 190 || + token.parent.kind === 191 || + token.parent.kind === 193) { return 5; } } @@ -52671,7 +53763,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 246 ? 24 : 6; + return token.parent.kind === 250 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -52685,32 +53777,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 222: + case 226: if (token.parent.name === token) { return 11; } return; - case 142: + case 143: if (token.parent.name === token) { return 15; } return; - case 223: + case 227: if (token.parent.name === token) { return 13; } return; - case 225: + case 229: if (token.parent.name === token) { return 12; } return; - case 226: + case 230: if (token.parent.name === token) { return 14; } return; - case 143: + case 144: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -52765,7 +53857,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 245) { + location.parent && location.parent.kind === 249) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -52787,13 +53879,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { - if (nameTable[name_46] === position) { + for (var name_43 in nameTable) { + if (nameTable[name_43] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), 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, @@ -52843,15 +53935,15 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 253 && - node.parent.parent.kind === 172 && + if (node.parent.kind === 257 && + node.parent.parent.kind === 176 && 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 === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -52914,7 +54006,7 @@ var ts; if (!type) { return; } - if (type.flags & 524288) { + if (type.flags & 65536) { ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); } else { @@ -53215,11 +54307,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_16; + currentDir = parent_14; } else { break; @@ -53351,9 +54443,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277: - case 275: - case 276: + case 282: + case 280: + case 281: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -53388,13 +54480,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_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_17.kind === 173) { + if (parent_15.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140) { + else if (parent_15.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -53407,7 +54499,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 249) { isStartingCloseTag = true; location = contextToken; } @@ -53452,7 +54544,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 === 177) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -53477,7 +54569,7 @@ var ts; symbols.push(symbol); } } - if (isJavaScriptFile && type.flags & 524288) { + if (isJavaScriptFile && type.flags & 65536) { var unionType = type; for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { var elementType = _c[_b]; @@ -53498,7 +54590,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { + if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -53519,9 +54611,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 256 || - scopeNode.kind === 190 || - scopeNode.kind === 248 || + scopeNode.kind === 261 || + scopeNode.kind === 194 || + scopeNode.kind === 252 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -53549,11 +54641,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 244) { + if (contextToken.parent.kind === 248) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 242; + if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 246; } } return false; @@ -53563,40 +54655,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; + return containingNodeKind === 179 + || containingNodeKind === 150 + || containingNodeKind === 180 + || containingNodeKind === 175 + || containingNodeKind === 192 + || containingNodeKind === 158; case 18: - return containingNodeKind === 175 - || containingNodeKind === 149 - || containingNodeKind === 176 - || containingNodeKind === 179 - || containingNodeKind === 165; + return containingNodeKind === 179 + || containingNodeKind === 150 + || containingNodeKind === 180 + || containingNodeKind === 183 + || containingNodeKind === 166; case 20: - return containingNodeKind === 171 - || containingNodeKind === 154 - || containingNodeKind === 141; - case 126: + return containingNodeKind === 175 + || containingNodeKind === 155 + || containingNodeKind === 142; case 127: + case 128: return true; case 22: - return containingNodeKind === 226; + return containingNodeKind === 230; case 16: - return containingNodeKind === 222; + return containingNodeKind === 226; case 57: - return containingNodeKind === 219 - || containingNodeKind === 188; + return containingNodeKind === 223 + || containingNodeKind === 192; case 13: - return containingNodeKind === 190; + return containingNodeKind === 194; case 14: - return containingNodeKind === 198; + return containingNodeKind === 202; case 113: case 111: case 112: - return containingNodeKind === 146; + return containingNodeKind === 147; } switch (previousToken.getText()) { case "public": @@ -53627,22 +54719,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172) { + if (objectLikeContainer.kind === 176) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168) { + else if (objectLikeContainer.kind === 172) { 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); } } @@ -53668,9 +54760,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 234 ? - 231 : - 237; + var declarationKind = namedImportsOrExports.kind === 238 ? + 235 : + 241; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -53691,9 +54783,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_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { + return parent_16; } break; } @@ -53706,8 +54798,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 234: case 238: + case 242: return contextToken.parent; } } @@ -53716,34 +54808,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_17 = 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 250: + case 251: + if (parent_17 && (parent_17.kind === 247 || parent_17.kind === 248)) { + return parent_17; } - else if (parent_19.kind === 246) { - return parent_19.parent; + else if (parent_17.kind === 250) { + return parent_17.parent; } break; case 9: - if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { - return parent_19.parent; + if (parent_17 && ((parent_17.kind === 250) || (parent_17.kind === 251))) { + return parent_17.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_17 && + parent_17.kind === 252 && + parent_17.parent && + (parent_17.parent.kind === 250)) { + return parent_17.parent.parent; } - if (parent_19 && parent_19.kind === 247) { - return parent_19.parent; + if (parent_17 && parent_17.kind === 251) { + return parent_17.parent; } break; } @@ -53752,16 +54844,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 180: - case 181: - case 221: + case 184: + case 185: + case 225: + case 149: case 148: - case 147: - case 150: case 151: case 152: case 153: case 154: + case 155: return true; } return false; @@ -53770,66 +54862,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 219 || - containingNodeKind === 220 || - containingNodeKind === 201 || - containingNodeKind === 225 || + return containingNodeKind === 223 || + containingNodeKind === 224 || + containingNodeKind === 205 || + containingNodeKind === 229 || isFunction(containingNodeKind) || - containingNodeKind === 222 || - containingNodeKind === 193 || - containingNodeKind === 223 || - containingNodeKind === 169 || - containingNodeKind === 224; + containingNodeKind === 226 || + containingNodeKind === 197 || + containingNodeKind === 227 || + containingNodeKind === 173 || + containingNodeKind === 228; case 22: - return containingNodeKind === 169; + return containingNodeKind === 173; case 55: - return containingNodeKind === 170; + return containingNodeKind === 174; case 20: - return containingNodeKind === 169; + return containingNodeKind === 173; case 18: - return containingNodeKind === 252 || + return containingNodeKind === 256 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 225 || - containingNodeKind === 223 || - containingNodeKind === 160; + return containingNodeKind === 229 || + containingNodeKind === 227 || + 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 === 227 || + contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 222 || - containingNodeKind === 193 || - containingNodeKind === 223 || - containingNodeKind === 224 || + return containingNodeKind === 226 || + containingNodeKind === 197 || + containingNodeKind === 227 || + containingNodeKind === 228 || 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 === 173); case 113: case 111: case 112: - return containingNodeKind === 143; + return containingNodeKind === 144; case 117: - return containingNodeKind === 235 || - containingNodeKind === 239 || - containingNodeKind === 233; + return containingNodeKind === 239 || + containingNodeKind === 243 || + containingNodeKind === 237; 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()) { @@ -53866,8 +54958,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_44 = element.propertyName || element.name; + existingImportsOrExports[name_44.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -53881,17 +54973,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 !== 257 && + m.kind !== 258 && + m.kind !== 174 && + 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 === 174 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -53910,7 +55004,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246) { + if (attr.kind === 250) { seenNames[attr.name.text] = true; } } @@ -53943,7 +55037,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, @@ -54007,7 +55101,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)) { @@ -54059,75 +55153,75 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 204)) { + if (hasKind(node.parent, 208)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 212)) { + if (hasKind(node.parent, 216)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 220)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 217)) { + if (hasKind(parent(parent(node)), 221)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 217)) { + if (hasKind(parent(node), 221)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 214)) { + if (hasKind(node.parent, 218)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 214)) { + if (hasKind(parent(parent(parent(node))), 218)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { + if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 207) || - hasKind(node.parent, 208) || - hasKind(node.parent, 209)) { + if (hasKind(node.parent, 211) || + hasKind(node.parent, 212) || + hasKind(node.parent, 213)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { + if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { 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 === 205)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -54139,10 +55233,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216) { + if (node.kind === 220) { statementAccumulator.push(node); } - else if (node.kind === 217) { + else if (node.kind === 221) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -54162,17 +55256,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_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 261) { + return parent_18; } - if (parent_20.kind === 217) { - var tryStatement = parent_20; + if (parent_18.kind === 221) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_18; } return undefined; } @@ -54181,7 +55275,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 || node.kind === 210) { + if (node.kind === 215 || node.kind === 214) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -54196,15 +55290,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 218: + if (statement.kind === 214) { continue; } - case 207: - case 208: + case 211: + case 212: + case 213: + case 210: case 209: - case 206: - case 205: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -54221,24 +55315,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 === 226 || + container.kind === 197 || + (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 222 || container.kind === 193)) { + if (!(container.kind === 226 || container.kind === 197)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 227 || container.kind === 256)) { + if (!(container.kind === 231 || container.kind === 261)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 222 || declaration.kind === 222)) { + if (!(container.kind === 226 || declaration.kind === 226)) { return undefined; } } @@ -54249,8 +55343,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227: - case 256: + case 231: + case 261: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -54258,15 +55352,15 @@ var ts; nodes = container.statements; } break; - case 149: + case 150: nodes = container.parameters.concat(container.parent.members); break; - case 222: - case 193: + case 226: + case 197: 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); @@ -54319,13 +55413,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); }); } } } @@ -54342,7 +55436,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 205) { + if (loopNode.kind === 209) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -54363,13 +55457,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 207: - case 208: + case 211: + case 212: + case 213: case 209: - case 205: - case 206: + case 210: return getLoopBreakContinueOccurrences(owner); - case 214: + case 218: return getSwitchCaseDefaultOccurrences(owner); } } @@ -54419,7 +55513,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 200))) { + if (!(func && hasKind(func.body, 204))) { return undefined; } var keywords = []; @@ -54433,7 +55527,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -54444,7 +55538,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204)) { + if (!hasKind(ifStatement.elseStatement, 208)) { break; } ifStatement = ifStatement.elseStatement; @@ -54479,7 +55573,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 === 219; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -54683,16 +55777,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 232); + var defaultImport = ts.getDeclarationOfKind(symbol, 236); 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 === 239 || + declaration.kind === 243) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 235 ? + return importOrExportSpecifier.kind === 239 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -54707,14 +55801,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 174); return bindingElement && - bindingElement.parent.kind === 168 && + bindingElement.parent.kind === 172 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 174); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -54730,13 +55824,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { + if (valueDeclaration && (valueDeclaration.kind === 184 || valueDeclaration.kind === 197)) { 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, 226); } } if (symbol.flags & 8388608) { @@ -54760,7 +55854,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 256 && !ts.isExternalModule(container)) { + if (container.kind === 261 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -54782,8 +55876,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); @@ -54893,7 +55987,7 @@ var ts; if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { return [localParentType.symbol]; } - else if (localParentType.flags & 1572864) { + else if (localParentType.flags & 196608) { return getSymbolsForClassAndInterfaceComponents(localParentType); } } @@ -54927,14 +56021,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) { @@ -54956,7 +56050,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) { @@ -54997,7 +56091,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 254) { + if (refNode.parent.kind === 258) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -55007,24 +56101,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_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.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_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 204) { + ts.forEachReturnStatement(parent_19.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_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -55041,7 +56135,7 @@ var ts; if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { result.push(componentType.symbol); } - if (componentType.getFlags() & 1572864) { + if (componentType.getFlags() & 196608) { getSymbolsForClassAndInterfaceComponents(componentType, result); } } @@ -55059,26 +56153,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 - && node.parent.kind === 251 + if (node.kind === 199 + && node.parent.kind === 255 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 70 || node.kind === 173) { + else if (node.kind === 70 || node.kind === 177) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 179) { + if (node.kind === 183) { return isImplementationExpression(node.expression); } - return node.kind === 181 || - node.kind === 180 || - node.kind === 172 || - node.kind === 193 || - node.kind === 171; + return node.kind === 185 || + node.kind === 184 || + node.kind === 176 || + node.kind === 197 || + node.kind === 175; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -55107,7 +56201,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223) { + else if (declaration.kind === 227) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -55134,13 +56228,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; @@ -55168,32 +56262,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 261: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 221: - case 180: + case 225: + case 184: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256) { + if (searchSpaceNode.kind === 261) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -55227,26 +56321,26 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 180: - case 221: + case 184: + case 225: 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 197: + case 226: 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 261: + if (container.kind === 261 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -55285,8 +56379,8 @@ var ts; if (!node_2 || node_2.kind !== 9) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { references.push(getReferenceEntryFromNode(node_2)); } } @@ -55295,7 +56389,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -55314,7 +56408,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)); } @@ -55345,7 +56439,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223) { + else if (declaration.kind === 227) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -55408,7 +56502,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; @@ -55427,7 +56521,7 @@ var ts; if (symbol_2) { result_4.push(symbol_2); } - if (contextualType.flags & 524288) { + if (contextualType.flags & 65536) { ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -55477,7 +56571,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219) { + else if (node.kind === 223) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -55487,18 +56581,18 @@ var ts; } else { switch (node.kind) { - case 222: - case 193: - case 225: case 226: + case 197: + case 229: + case 230: 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 === 205) { + ts.Debug.assert(node.parent.kind === 224); return node.parent.parent; } } @@ -55536,10 +56630,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 || parent.kind === 186) { + if (parent.kind === 191 || parent.kind === 190) { return true; } - else if (parent.kind === 188 && parent.left === node) { + else if (parent.kind === 192 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -55558,7 +56652,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: @@ -55568,11 +56662,11 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 253: - case 254: - case 148: - case 150: + case 257: + case 258: + case 149: case 151: + case 152: return true; } return false; @@ -55631,11 +56725,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 === 239 && declaration.parent && declaration.parent.kind === 238))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 254) { + if (node.parent.kind === 258) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -55662,7 +56756,7 @@ var ts; if (!type) { return undefined; } - if (type.flags & 524288 && !(type.flags & 16)) { + if (type.flags & 65536 && !(type.flags & 16)) { var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { @@ -55712,8 +56806,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 === 225 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -55789,7 +56883,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 254) { + if (node.parent.kind === 258) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -55914,16 +57008,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 221: - case 148: + case 225: case 149: - case 222: - case 201: - break findOwner; - case 256: - return undefined; + case 150: case 226: - if (commentOwner.parent.kind === 226) { + case 205: + break findOwner; + case 261: + return undefined; + case 230: + if (commentOwner.parent.kind === 230) { return undefined; } break findOwner; @@ -55957,7 +57051,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201) { + if (commentOwner.kind === 205) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -55967,17 +57061,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 179) { + while (rightHandSide.kind === 183) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180: - case 181: + case 184: + case 185: return rightHandSide.parameters; - case 193: + case 197: 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; } } @@ -55988,147 +57082,6 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { - var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typingOptions.include); - exclude = typingOptions.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - for (var name_48 in packageNameToTypingLocation) { - if (name_48 in inferredTypings && !inferredTypings[name_48]) { - inferredTypings[name_48] = packageNameToTypingLocation[name_48]; - } - } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - filesToWatch.push(jsonPath); - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { @@ -56141,10 +57094,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; } @@ -56155,21 +57108,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 === 236 || decl.kind === 239 || decl.kind === 234) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -56210,7 +57163,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 { @@ -56227,7 +57180,7 @@ var ts; } return true; } - if (expression.kind === 173) { + if (expression.kind === 177) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -56238,7 +57191,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; } @@ -56370,7 +57323,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++) { @@ -56380,28 +57333,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 236: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 237) { addLeafNode(namedBindings); } else { @@ -56412,12 +57365,12 @@ var ts; } } break; - case 170: - case 219: + case 174: + case 223: 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); @@ -56426,12 +57379,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181: - case 221: - case 180: + case 185: + case 225: + case 184: addNodeWithRecursiveChild(node, node.body); break; - case 225: + case 229: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -56441,9 +57394,9 @@ var ts; } endNode(); break; - case 222: - case 193: - case 223: + case 226: + case 197: + case 227: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -56451,21 +57404,21 @@ var ts; } endNode(); break; - case 226: + case 230: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 239: - case 230: - case 154: - case 152: + case 243: + case 234: + case 155: case 153: - case 224: + case 154: + case 228: addLeafNode(node); break; default: ts.forEach(node.jsDocComments, function (jsDocComment) { ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279) { + if (tag.kind === 284) { addLeafNode(tag); } }); @@ -56513,12 +57466,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 !== 230 || 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 !== 230) { return true; } return areSameModule(a.body, b.body); @@ -56569,7 +57522,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 226) { + if (node.kind === 230) { return getModuleName(node); } var decl = node; @@ -56577,18 +57530,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180: - case 181: - case 193: + case 184: + case 185: + case 197: return getFunctionOrClassName(node); - case 279: + case 284: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226) { + if (node.kind === 230) { return getModuleName(node); } var name = node.name; @@ -56599,29 +57552,29 @@ var ts; } } switch (node.kind) { - case 256: + case 261: 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 185: + case 225: + case 184: + case 226: + case 197: 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 284: return getJSDocTypedefTagName(node); default: return ""; @@ -56633,7 +57586,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 205) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -56661,24 +57614,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 222: - case 193: - case 225: - case 223: case 226: - case 256: - case 224: - case 279: + case 197: + case 229: + case 227: + case 230: + case 261: + case 228: + case 284: return true; - case 149: - case 148: case 150: + case 149: case 151: - case 219: + case 152: + case 223: return hasSomeImportantChild(item); - case 181: - case 221: - case 180: + case 185: + case 225: + case 184: return isTopLevelFunctionDeclaration(item); default: return false; @@ -56688,10 +57641,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227: - case 256: - case 148: + case 231: + case 261: case 149: + case 150: return true; default: return hasSomeImportantChild(item); @@ -56700,7 +57653,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 219 && childKind !== 170; + return childKind !== 223 && childKind !== 174; }); } } @@ -56755,20 +57708,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { 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 === 230 ? 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 === 261 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -56776,14 +57729,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 === 223) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 && + else if (node.parent.kind === 192 && node.parent.operatorToken.kind === 57) { - return nodeText(node.parent.left); + return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 && node.parent.name) { + else if (node.parent.kind === 257 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -56794,8 +57747,9 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 || node.kind === 181 || node.kind === 193; + return node.kind === 184 || node.kind === 185 || node.kind === 197; } + var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); var ts; @@ -56866,7 +57820,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181; + return ts.isFunctionBlock(node) && node.parent.kind !== 185; } var depth = 0; var maxDepth = 20; @@ -56878,26 +57832,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200: + case 204: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_20 = 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_20.kind === 209 || + parent_20.kind === 212 || + parent_20.kind === 213 || + parent_20.kind === 211 || + parent_20.kind === 208 || + parent_20.kind === 210 || + parent_20.kind === 217 || + parent_20.kind === 256) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217) { - var tryStatement = parent_22; + if (parent_20.kind === 221) { + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -56917,23 +57871,23 @@ var ts; }); break; } - case 227: { + case 231: { 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 227: + case 229: + case 176: + case 232: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 171: + case 175: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -56951,13 +57905,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, @@ -57178,7 +58132,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); @@ -57188,7 +58142,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); @@ -57424,7 +58378,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(); @@ -57445,7 +58399,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57471,7 +58425,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57485,7 +58439,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(); @@ -57511,7 +58465,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57521,7 +58475,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57545,7 +58499,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(); @@ -57739,12 +58693,6 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; - (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; function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -57770,14 +58718,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175) { + if (argumentInfo.invocation.kind !== 179) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 173 + : expression.kind === 177 ? expression.name : undefined; if (!name || !name.text) { @@ -57806,7 +58754,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 175 || node.parent.kind === 176) { + if (node.parent.kind === 179 || node.parent.kind === 180) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -57838,23 +58786,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 177) { + else if (node.kind === 12 && node.parent.kind === 181) { 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 === 181) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 194); 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 === 202 && node.parent.parent.parent.kind === 181) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 194); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -57918,7 +58866,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 190) { + if (template.kind === 194) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -57927,7 +58875,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 !== 261; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -57977,7 +58925,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; @@ -57988,6 +58938,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); }); @@ -58002,7 +58953,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], @@ -58056,7 +59007,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 193) ? + return ts.getDeclarationOfKind(symbol, 197) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -58156,14 +59107,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 === 177) { 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 === 179 || location.kind === 180) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -58175,7 +59126,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpression.kind === 180 || 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; @@ -58211,7 +59162,7 @@ var ts; displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 2097152) && type.symbol) { + if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); } addSignatureDisplayParts(signature, allSignatures, 8); @@ -58223,21 +59174,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); @@ -58246,7 +59197,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193)) { + if (ts.getDeclarationOfKind(symbol, 197)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -58265,7 +59216,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); @@ -58286,9 +59237,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226); + var declaration = ts.getDeclarationOfKind(symbol, 230); 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); } @@ -58299,31 +59250,31 @@ var ts; displayParts.push(ts.punctuationPart(19)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91)); - displayParts.push(ts.spacePart()); if (symbol.parent) { + addInPrefix(); addFullSymbolName(symbol.parent, enclosingDeclaration); 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)) { + addInPrefix(); 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)); + else if (declaration.kind === 228) { + addInPrefix(); + displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -58334,7 +59285,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255) { + if (declaration.kind === 260) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -58346,10 +59297,10 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229) { + if (symbol.declarations[0].kind === 233) { 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)); @@ -58357,13 +59308,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230) { + if (declaration.kind === 234) { 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)); @@ -58425,10 +59376,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 === 261; })) { 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 !== 192) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -58449,6 +59400,11 @@ var ts; displayParts.push(ts.lineBreakPart()); } } + function addInPrefix() { + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(91)); + displayParts.push(ts.spacePart()); + } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); ts.addRange(displayParts, fullSymbolDisplayParts); @@ -58503,14 +59459,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 180) { + if (declaration.kind === 184) { return true; } - if (declaration.kind !== 219 && declaration.kind !== 221) { + if (declaration.kind !== 223 && declaration.kind !== 225) { 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_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + if (parent_21.kind === 261 || parent_21.kind === 231) { return false; } } @@ -58594,7 +59550,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -58610,7 +59566,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_4(opt); } return options; } @@ -58619,18 +59575,9 @@ 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; - var ScanAction; - (function (ScanAction) { - ScanAction[ScanAction["Scan"] = 0] = "Scan"; - ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; - ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; - ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; - ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; - ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; - })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; @@ -58710,10 +59657,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 246: - case 244: - case 245: - case 243: + case 250: + case 248: + case 249: + case 247: return node.kind === 70; } } @@ -58924,20 +59871,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var formatting; - (function (formatting) { - (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; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var formatting; (function (formatting) { @@ -58959,19 +59892,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var formatting; - (function (formatting) { - (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; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var formatting; (function (formatting) { @@ -59002,17 +59922,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var formatting; - (function (formatting) { - (function (RuleFlags) { - RuleFlags[RuleFlags["None"] = 0] = "None"; - RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; - })(formatting.RuleFlags || (formatting.RuleFlags = {})); - var RuleFlags = formatting.RuleFlags; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var formatting; (function (formatting) { @@ -59126,13 +60035,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)); @@ -59146,7 +60055,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)); @@ -59251,43 +60160,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 === 211; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 188: - case 189: - case 196: + case 192: + case 193: + case 200: + case 243: case 239: - case 235: - case 155: - case 163: + case 156: case 164: + case 165: return true; - case 170: - case 224: - case 230: - case 219: - case 143: - case 255: + case 174: + case 228: + case 234: + case 223: + case 144: + case 260: + case 147: case 146: - case 145: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 208: + case 212: return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; - case 209: - return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; + case 213: + return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; }; @@ -59295,7 +60204,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189; + return context.contextNode.kind === 193; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -59320,90 +60229,90 @@ var ts; return true; } switch (node.kind) { - case 200: - case 228: - case 172: - case 227: + case 204: + case 232: + case 176: + case 231: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221: + case 225: + case 149: case 148: - case 147: - case 150: case 151: case 152: - case 180: - case 149: - case 181: - case 223: + case 153: + case 184: + case 150: + case 185: + case 227: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 || context.contextNode.kind === 180; + return context.contextNode.kind === 225 || context.contextNode.kind === 184; }; 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 226: - case 237: + case 197: + case 227: + case 229: + case 161: + case 230: + case 241: + case 242: + case 235: case 238: - case 231: - case 234: 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 230: + case 229: + case 204: + case 256: + case 231: + case 218: 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 218: + case 211: + case 212: case 213: - case 252: + case 210: + case 221: + case 209: + case 217: + case 256: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172; + return context.contextNode.kind === 176; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 175; + return context.contextNode.kind === 179; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 180; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -59415,25 +60324,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 185; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 242; + return context.contextNode.kind !== 246; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248; + return context.contextNode.kind === 252; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246; + return context.nextTokenParent.kind === 250; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246; + return context.contextNode.kind === 250; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243; + return context.contextNode.kind === 247; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -59448,41 +60357,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 === 224 && 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 === 230; }; 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 181: + case 157: + case 182: + case 226: + case 197: + case 227: + case 225: + case 184: + case 185: + case 149: case 148: - case 147: - case 152: case 153: - case 175: - case 176: - case 195: + case 154: + case 179: + case 180: + case 199: return true; default: return false; @@ -59493,13 +60402,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178; + return context.contextNode.kind === 182; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 188; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -59521,7 +60430,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); @@ -59534,7 +60443,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; }; @@ -59571,6 +60480,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"; @@ -59578,8 +60488,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; @@ -59698,7 +60607,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; @@ -59742,9 +60651,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]); @@ -59752,7 +60661,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 = {})); @@ -59888,10 +60797,6 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var Constants; - (function (Constants) { - Constants[Constants["Unknown"] = -1] = "Unknown"; - })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -59964,17 +60869,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 222: - case 223: - return ts.rangeContainsRange(parent.members, node); case 226: - var body = parent.body; - return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); - case 256: - case 200: case 227: + return ts.rangeContainsRange(parent.members, node); + case 230: + var body = parent.body; + return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); + case 261: + case 204: + case 231: return ts.rangeContainsRange(parent.statements, node); - case 252: + case 256: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -60130,18 +61035,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 226: return 74; + case 227: return 108; + case 225: return 88; + case 229: return 229; + 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; } } @@ -60257,11 +61162,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 === 175 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -60565,12 +61470,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 150: + case 225: + case 184: case 149: - case 221: - case 180: case 148: - case 147: - case 181: + case 185: if (node.typeParameters === list) { return 26; } @@ -60578,8 +61483,8 @@ var ts; return 18; } break; - case 175: - case 176: + case 179: + case 180: if (node.typeArguments === list) { return 26; } @@ -60587,7 +61492,7 @@ var ts; return 18; } break; - case 156: + case 157: if (node.typeArguments === list) { return 26; } @@ -60660,10 +61565,6 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { - var Value; - (function (Value) { - Value[Value["Unknown"] = -1] = "Unknown"; - })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -60692,7 +61593,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 !== 192) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -60794,7 +61695,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 === 261 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -60818,7 +61719,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 === 208 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -60830,23 +61731,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 176: return node.parent.properties; - case 171: + case 175: return node.parent.elements; - case 221: - case 180: - case 181: + case 225: + case 184: + case 185: + 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())) { @@ -60857,8 +61758,8 @@ var ts; } break; } - case 176: - case 175: { + case 180: + case 179: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -60886,8 +61787,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 === 179 || + node.parent.kind === 180) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -60905,10 +61806,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175: - case 176: - case 173: - case 174: + case 179: + case 180: + case 177: + case 178: node = node.expression; break; default: @@ -60962,48 +61863,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 203: - case 222: - case 193: - case 223: - case 225: - case 224: - case 171: - case 200: + case 207: + case 226: + case 197: case 227: - case 172: - case 160: - case 162: + case 229: case 228: - case 250: - case 249: - case 179: - case 173: case 175: + case 204: + case 231: 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 161: + case 163: + case 232: + case 254: + case 253: + case 183: case 177: - case 185: + case 179: + case 180: + case 205: + case 223: + case 240: + case 216: + case 193: + case 173: + case 172: + case 248: + case 247: + case 252: + case 148: + case 153: + case 154: + case 144: + case 158: + case 159: + case 166: + case 181: + case 189: + case 242: case 238: - case 234: + case 243: case 239: - case 235: return true; } return false; @@ -61011,27 +61912,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 207: - case 204: - case 221: - case 180: - case 148: - case 181: + case 210: + case 212: + case 213: + case 211: + case 208: + case 225: + case 184: case 149: + case 185: 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 !== 204; + case 241: + return childKind !== 242; + case 235: + return childKind !== 236 || + (child.namedBindings && child.namedBindings.kind !== 238); + case 246: + return childKind !== 249; } return indentByDefault; } @@ -61112,7 +62013,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 175) { + if (superCall.expression && superCall.expression.kind == 179) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -61136,7 +62037,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 && ts.isSuperCall(n.expression)) { + if (n.kind === 207 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -61152,7 +62053,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; @@ -61164,7 +62065,6 @@ var ts; this.end = end; this.flags = 0; this.transformFlags = undefined; - this.excludeTransformFlags = undefined; this.parent = undefined; this.kind = kind; } @@ -61211,11 +62111,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286, nodes.pos, nodes.end, this); + var list = createNode(291, 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); } @@ -61230,11 +62130,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 >= 278 && this.kind <= 290; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -61288,7 +62188,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); @@ -61296,7 +62196,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; }()); @@ -61423,7 +62323,7 @@ var ts; return this.checker.getIndexTypeOfType(this, 1); }; TypeObject.prototype.getBaseTypes = function () { - return this.flags & (32768 | 65536) + return this.flags & 32768 && this.objectFlags & (1 | 2) ? this.checker.getBaseTypes(this) : undefined; }; @@ -61498,9 +62398,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 === 177) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -61520,10 +62420,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221: - case 180: + case 225: + case 184: + case 149: case 148: - case 147: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -61540,30 +62440,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 222: - case 193: - case 223: - case 224: - case 225: case 226: + case 197: + case 227: + case 228: + case 229: case 230: + case 234: + case 243: case 239: - case 235: - case 230: - case 232: - case 233: - case 150: + case 234: + case 236: + case 237: 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 223: + case 174: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -61572,24 +62472,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255: + case 260: + case 147: case 146: - case 145: addDeclaration(node); break; - case 237: + case 241: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 231: + case 235: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 237) { addDeclaration(importClause.namedBindings); } else { @@ -61735,7 +62635,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); @@ -61888,7 +62788,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function () { }, + writeFile: ts.noop, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -62031,10 +62931,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 173: - case 140: + case 177: + case 141: case 98: - case 166: + case 167: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -62163,15 +63063,15 @@ var ts; return; } switch (node.kind) { - case 173: - case 140: + case 177: + case 141: case 9: case 85: case 100: case 94: case 96: case 98: - case 166: + case 167: case 70: break; default: @@ -62183,7 +63083,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 226 && + if (nodeForStartPos.parent.parent.kind === 230 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -62479,7 +63379,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 241 || + node.parent.kind === 245 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -62499,7 +63399,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 && + node.parent.kind === 178 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -62514,933 +63414,6 @@ var ts; } initializeServices(); })(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - 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; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); - } - } - } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; - } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (_dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; - } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); - } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typingOptions: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; - } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typingOptions: configFile.typingOptions, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); - } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); - } - catch (err) { - logInternalError(logger, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; - } - } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } -})(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.1"; -var ts; -(function (ts) { - var server; - (function (server) { - (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; - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typingOptions, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(), - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function throwLanguageServiceIsDisabledError() { - throw new Error("LanguageService is disabled"); - } - server.nullLanguageService = { - cleanupSemanticCache: throwLanguageServiceIsDisabledError, - getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, - getSemanticDiagnostics: throwLanguageServiceIsDisabledError, - getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, - getSyntacticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, - getSemanticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, - getCompletionsAtPosition: throwLanguageServiceIsDisabledError, - findReferences: throwLanguageServiceIsDisabledError, - getCompletionEntryDetails: throwLanguageServiceIsDisabledError, - getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, - findRenameLocations: throwLanguageServiceIsDisabledError, - getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, - getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, - getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, - getSignatureHelpItems: throwLanguageServiceIsDisabledError, - getDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getRenameInfo: throwLanguageServiceIsDisabledError, - getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getReferencesAtPosition: throwLanguageServiceIsDisabledError, - getDocumentHighlights: throwLanguageServiceIsDisabledError, - getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, - getNavigateToItems: throwLanguageServiceIsDisabledError, - getNavigationBarItems: throwLanguageServiceIsDisabledError, - getNavigationTree: throwLanguageServiceIsDisabledError, - getOutliningSpans: throwLanguageServiceIsDisabledError, - getTodoComments: throwLanguageServiceIsDisabledError, - getIndentationAtPosition: throwLanguageServiceIsDisabledError, - getFormattingEditsForRange: throwLanguageServiceIsDisabledError, - getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, - getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, - getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, - isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, - getEmitOutput: throwLanguageServiceIsDisabledError, - getProgram: throwLanguageServiceIsDisabledError, - getNonBoundSourceFile: throwLanguageServiceIsDisabledError, - dispose: throwLanguageServiceIsDisabledError, - getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, - getImplementationAtPosition: throwLanguageServiceIsDisabledError, - getSourceFile: throwLanguageServiceIsDisabledError, - getCodeFixesAtPosition: throwLanguageServiceIsDisabledError - }; - server.nullLanguageServiceHost = { - setCompilationSettings: function () { return undefined; }, - notifyFileRemoved: function () { return undefined; } - }; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -63607,55 +63580,58 @@ 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.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { + LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { + this.filesWithChangedSetOfUnresolvedImports = []; + }; + LSHost.prototype.finishRecordingFilesWithChangedResolutions = function () { + var collected = this.filesWithChangedSetOfUnresolvedImports; + this.filesWithChangedSetOfUnresolvedImports = undefined; + return collected; + }; + 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); + logChanges = false; } } ts.Debug.assert(resolution !== undefined); @@ -63663,16 +63639,30 @@ var ts; } cache.set(path, newResolutions); return resolvedModules; + function resolutionIsEqualTo(oldResolution, newResolution) { + if (oldResolution === newResolution) { + return true; + } + if (!oldResolution || !newResolution) { + return false; + } + var oldResult = getResult(oldResolution); + var newResult = getResult(newResolution); + if (oldResult === newResult) { + return true; + } + if (!oldResult || !newResult) { + return false; + } + return getResultFileName(oldResult) === getResultFileName(newResult); + } function moduleResolutionIsValid(resolution) { if (!resolution) { return false; } 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; } @@ -63690,10 +63680,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; }); + 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; }); + 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())); @@ -63745,9 +63735,11 @@ var ts; this.resolvedTypeReferenceDirectives.remove(info.path); }; LSHost.prototype.setCompilationSettings = function (opt) { + if (ts.changesAffectModuleResolution(this.compilationSettings, opt)) { + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + } this.compilationSettings = opt; - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); }; return LSHost; }()); @@ -63759,9 +63751,9 @@ var ts; var server; (function (server) { server.nullTypingsInstaller = { - enqueueInstallTypingsRequest: function () { }, - attach: function () { }, - onProjectClosed: function () { }, + enqueueInstallTypingsRequest: ts.noop, + attach: ts.noop, + onProjectClosed: ts.noop, globalTypingsCacheLocation: undefined }; var TypingsCacheEntry = (function () { @@ -63805,48 +63797,52 @@ var ts; function compilerOptionsChanged(opt1, opt2) { return opt1.allowJs != opt2.allowJs; } - function toTypingsArray(arr) { - arr.sort(); - return arr; + function unresolvedImportsChanged(imports1, imports2) { + if (imports1 === imports2) { + return false; + } + return !ts.arrayIsEqualTo(imports1, imports2); } var TypingsCache = (function () { function TypingsCache(installer) { this.installer = installer; this.perProjectCache = ts.createMap(); } - TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { + TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { var typingOptions = project.getTypingOptions(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return server.emptyArray; } var entry = this.perProjectCache[project.getProjectName()]; var result = entry ? entry.typings : server.emptyArray; - if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { + if (forceRefresh || + !entry || + typingOptionsChanged(typingOptions, entry.typingOptions) || + compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || + unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { this.perProjectCache[project.getProjectName()] = { compilerOptions: project.getCompilerOptions(), typingOptions: typingOptions, typings: result, + unresolvedImports: unresolvedImports, poisoned: true }; - this.installer.enqueueInstallTypingsRequest(project, typingOptions); + this.installer.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports); } return result; }; - TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions.enableAutoDiscovery) { - return; - } - this.installer.enqueueInstallTypingsRequest(project, typingOptions); - }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, unresolvedImports, newTypings) { this.perProjectCache[projectName] = { compilerOptions: compilerOptions, typingOptions: typingOptions, - typings: toTypingsArray(newTypings), + typings: server.toSortedReadonlyArray(newTypings), + unresolvedImports: unresolvedImports, poisoned: false }; }; + TypingsCache.prototype.deleteTypingsForProject = function (projectName) { + delete this.perProjectCache[projectName]; + }; TypingsCache.prototype.onProjectClosed = function (project) { delete this.perProjectCache[project.getProjectName()]; this.installer.onProjectClosed(project); @@ -63860,7 +63856,6 @@ var ts; (function (ts) { var server; (function (server) { - var crypto = require("crypto"); function shouldEmitFile(scriptInfo) { return !scriptInfo.hasMixedContent; } @@ -63877,16 +63872,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 !== 230 || 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); @@ -64162,12 +64155,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) { @@ -64211,6 +64204,32 @@ var ts; return counts.ts === 0 && counts.tsx === 0; } server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var UnresolvedImportsMap = (function () { + function UnresolvedImportsMap() { + this.perFileMap = ts.createFileMap(); + this.version = 0; + } + UnresolvedImportsMap.prototype.clear = function () { + this.perFileMap.clear(); + this.version = 0; + }; + UnresolvedImportsMap.prototype.getVersion = function () { + return this.version; + }; + UnresolvedImportsMap.prototype.remove = function (path) { + this.perFileMap.remove(path); + this.version++; + }; + UnresolvedImportsMap.prototype.get = function (path) { + return this.perFileMap.get(path); + }; + UnresolvedImportsMap.prototype.set = function (path, value) { + this.perFileMap.set(path, value); + this.version++; + }; + return UnresolvedImportsMap; + }()); + server.UnresolvedImportsMap = UnresolvedImportsMap; var Project = (function () { function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { this.projectKind = projectKind; @@ -64221,6 +64240,7 @@ var ts; this.compileOnSaveEnabled = compileOnSaveEnabled; this.rootFiles = []; this.rootFilesMap = ts.createFileMap(); + this.cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); this.lastReportedVersion = 0; this.projectStructureVersion = 0; this.projectStateVersion = 0; @@ -64233,6 +64253,9 @@ var ts; else if (hasExplicitListOfFiles) { this.compilerOptions.allowNonTsExtensions = true; } + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; + } if (languageServiceEnabled) { this.enableLanguageService(); } @@ -64250,6 +64273,9 @@ var ts; this.updateGraph(); return hasOneOrMoreJsAndNoTsFiles(this); }; + Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { + return this.cachedUnresolvedImportsPerFile; + }; Project.prototype.getProjectErrors = function () { return this.projectErrors; }; @@ -64356,7 +64382,7 @@ var ts; } return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; - Project.prototype.getFileNames = function () { + Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { if (!this.program) { return []; } @@ -64370,8 +64396,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) { @@ -64412,6 +64445,7 @@ var ts; if (detachFromProject === void 0) { detachFromProject = true; } this.removeRootFileIfNecessary(info); this.lsHost.notifyFileRemoved(info); + this.cachedUnresolvedImportsPerFile.remove(info.path); if (detachFromProject) { info.detachFromProject(this); } @@ -64420,12 +64454,56 @@ var ts; Project.prototype.markAsDirty = function () { this.projectStateVersion++; }; + Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { + var cached = this.cachedUnresolvedImportsPerFile.get(file.path); + if (cached) { + for (var _i = 0, cached_1 = cached; _i < cached_1.length; _i++) { + var f = cached_1[_i]; + result.push(f); + } + return; + } + var unresolvedImports; + if (file.resolvedModules) { + 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); + } + if (i !== -1) { + trimmed = trimmed.substr(0, i); + } + (unresolvedImports || (unresolvedImports = [])).push(trimmed); + result.push(trimmed); + } + } + } + this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); + }; Project.prototype.updateGraph = function () { if (!this.languageServiceEnabled) { return true; } + this.lsHost.startRecordingFilesWithChangedResolutions(); var hasChanges = this.updateGraphWorker(); - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); + var changedFiles = this.lsHost.finishRecordingFilesWithChangedResolutions() || server.emptyArray; + for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { + var file = changedFiles_1[_i]; + this.cachedUnresolvedImportsPerFile.remove(file); + } + var unresolvedImports; + if (hasChanges || changedFiles.length) { + var result = []; + for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { + var sourceFile = _b[_a]; + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = server.toSortedReadonlyArray(result); + } + unresolvedImports = this.lastCachedUnresolvedImportsList; + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); if (this.setTypings(cachedTypings)) { hasChanges = this.updateGraphWorker() || hasChanges; } @@ -64498,6 +64576,10 @@ var ts; compilerOptions.allowJs = true; } compilerOptions.allowNonTsExtensions = true; + if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { + this.cachedUnresolvedImportsPerFile.clear(); + this.lastCachedUnresolvedImportsList = undefined; + } this.compilerOptions = compilerOptions; this.lsHost.setCompilationSettings(compilerOptions); this.markAsDirty(); @@ -64606,9 +64688,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++; @@ -64938,6 +65019,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); @@ -64964,17 +65046,18 @@ var ts; return; } switch (response.kind) { - case "set": - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); - project.updateGraph(); + case server.ActionSet: + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.unresolvedImports, response.typings); break; - case "invalidate": - this.typingsCache.invalidateCachedTypingsForProject(project); + case server.ActionInvalidate: + this.typingsCache.deleteTypingsForProject(response.projectName); break; } + project.updateGraph(); }; 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]; @@ -65525,7 +65608,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(); @@ -65658,13 +65741,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_3 = 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_3(proj); + _loop_5(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -65686,8 +65769,8 @@ var ts; } } if (changedFiles) { - for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { - var file = changedFiles_1[_a]; + for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) { + var file = changedFiles_2[_a]; var scriptInfo = this.getScriptInfo(file.fileName); ts.Debug.assert(!!scriptInfo); for (var i = file.changes.length - 1; i >= 0; i--) { @@ -65754,7 +65837,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); @@ -66887,9 +66972,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_53 = 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_53, 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); }); @@ -67292,6 +67377,7 @@ var ts; var server; (function (server) { var lineCollectionCapacity = 4; + var CharRangeSection; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -67299,8 +67385,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; @@ -68144,13 +68229,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); @@ -68235,26 +68332,48 @@ var ts; return Logger; }()); var NodeTypingsInstaller = (function () { - function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) { + function NodeTypingsInstaller(telemetryEnabled, logger, host, eventPort, globalTypingsCacheLocation, newLine) { var _this = this; + this.telemetryEnabled = telemetryEnabled; this.logger = logger; this.globalTypingsCacheLocation = globalTypingsCacheLocation; this.newLine = newLine; + this.installerPidReported = false; + this.throttledOperations = new server.ThrottledOperations(host); if (eventPort) { var s_1 = net.connect({ port: eventPort }, function () { _this.socket = s_1; + _this.reportInstallerProcessId(); }); } } + NodeTypingsInstaller.prototype.reportInstallerProcessId = function () { + if (this.installerPidReported) { + return; + } + if (this.socket && this.installer) { + this.sendEvent(0, "typingsInstallerPid", { pid: this.installer.pid }); + this.installerPidReported = true; + } + }; + NodeTypingsInstaller.prototype.sendEvent = function (seq, event, body) { + this.socket.write(server.formatMessage({ seq: seq, type: "event", event: event, body: body }, this.logger, Buffer.byteLength, this.newLine), "utf8"); + }; + NodeTypingsInstaller.prototype.setTelemetrySender = function (telemetrySender) { + this.telemetrySender = telemetrySender; + }; NodeTypingsInstaller.prototype.attach = function (projectService) { var _this = this; this.projectService = projectService; if (this.logger.hasLevel(server.LogLevel.requestTime)) { this.logger.info("Binding..."); } - var args = ["--globalTypingsCacheLocation", this.globalTypingsCacheLocation]; + var args = [server.Arguments.GlobalCacheLocation, this.globalTypingsCacheLocation]; + if (this.telemetryEnabled) { + args.push(server.Arguments.EnableTelemetry); + } if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { - args.push("--logFile", ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); + args.push(server.Arguments.LogFile, ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); } var execArgv = []; { @@ -68272,6 +68391,7 @@ var ts; } this.installer = childProcess.fork(ts.combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv: execArgv }); this.installer.on("message", function (m) { return _this.handleMessage(m); }); + this.reportInstallerProcessId(); process.on("exit", function () { _this.installer.kill(); }); @@ -68279,30 +68399,58 @@ var ts; NodeTypingsInstaller.prototype.onProjectClosed = function (p) { this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" }); }; - NodeTypingsInstaller.prototype.enqueueInstallTypingsRequest = function (project, typingOptions) { - var request = server.createInstallTypingsRequest(project, typingOptions); + NodeTypingsInstaller.prototype.enqueueInstallTypingsRequest = function (project, typingOptions, unresolvedImports) { + var _this = this; + var request = server.createInstallTypingsRequest(project, typingOptions, unresolvedImports); if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Sending request: " + JSON.stringify(request)); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Scheduling throttled operation: " + JSON.stringify(request)); + } } - this.installer.send(request); + this.throttledOperations.schedule(project.getProjectName(), 250, function () { + if (_this.logger.hasLevel(server.LogLevel.verbose)) { + _this.logger.info("Sending request: " + JSON.stringify(request)); + } + _this.installer.send(request); + }); }; NodeTypingsInstaller.prototype.handleMessage = function (response) { if (this.logger.hasLevel(server.LogLevel.verbose)) { this.logger.info("Received response: " + JSON.stringify(response)); } + if (response.kind === server.EventInstall) { + if (this.telemetrySender) { + var body = { + telemetryEventName: "typingsInstalled", + payload: { + installedPackages: response.packagesToInstall.join(","), + installSuccess: response.installSuccess + } + }; + var eventName = "telemetry"; + this.telemetrySender.event(body, eventName); + } + return; + } this.projectService.updateTypingsForProject(response); - if (response.kind == "set" && this.socket) { - this.socket.write(server.formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8"); + if (response.kind == server.ActionSet && this.socket) { + this.sendEvent(0, "setTypings", response); } }; return NodeTypingsInstaller; }()); var IOSession = (function (_super) { __extends(IOSession, _super); - function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, logger) { - return _super.call(this, host, cancellationToken, useSingleInferredProject, disableAutomaticTypingAcquisition - ? server.nullTypingsInstaller - : new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; + function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, telemetryEnabled, logger) { + var _this; + var typingsInstaller = disableAutomaticTypingAcquisition + ? undefined + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); + _this = _super.call(this, host, cancellationToken, useSingleInferredProject, typingsInstaller || server.nullTypingsInstaller, Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; + if (telemetryEnabled && typingsInstaller) { + typingsInstaller.setTelemetrySender(_this); + } + return _this; } IOSession.prototype.exit = function () { this.logger.info("Exiting..."); @@ -68482,17 +68630,16 @@ var ts; ; var eventPort; { - var index = sys.args.indexOf("--eventPort"); - if (index >= 0 && index < sys.args.length - 1) { - var v = parseInt(sys.args[index + 1]); - if (!isNaN(v)) { - eventPort = v; - } + var str = server.findArgument("--eventPort"); + var v = str && parseInt(str); + if (!isNaN(v)) { + eventPort = v; } } - var useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0; - var disableAutomaticTypingAcquisition = sys.args.indexOf("--disableAutomaticTypingAcquisition") >= 0; - var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), logger); + var useSingleInferredProject = server.hasArgument("--useSingleInferredProject"); + var disableAutomaticTypingAcquisition = server.hasArgument("--disableAutomaticTypingAcquisition"); + var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry); + var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), telemetryEnabled, logger); process.on("uncaughtException", function (err) { ioSession.logError(err, "unknown"); }); @@ -68500,5 +68647,701 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); - -//# sourceMappingURL=tsserver.js.map +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { + return { + resolvedFileName: undefined, + failedLookupLocations: [] + }; + } + return { + resolvedFileName: resolvedFileName, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typingOptions: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typingOptions: configFile.typingOptions, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.unresolvedImports); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.2"; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 63580ce8dcd..9888241431b 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,20 +1,840 @@ -/*! ***************************************************************************** -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. -***************************************************************************** */ - /// -/// +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceFull = "brace-full"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionsFull = "completions-full"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type DefinitionFull = "definition-full"; + type Implementation = "implementation"; + type ImplementationFull = "implementation-full"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type FormatFull = "format-full"; + type FormatonkeyFull = "formatonkey-full"; + type FormatRangeFull = "formatRange-full"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type NavBarFull = "navbar-full"; + type Navto = "navto"; + type NavtoFull = "navto-full"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type DocumentHighlightsFull = "documentHighlights-full"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type QuickinfoFull = "quickinfo-full"; + type References = "references"; + type ReferencesFull = "references-full"; + type Reload = "reload"; + type Rename = "rename"; + type RenameInfoFull = "rename-full"; + type RenameLocationsFull = "renameLocations-full"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type SignatureHelpFull = "signatureHelp-full"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type SynchronizeProjectList = "synchronizeProjectList"; + type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + type Cleanup = "cleanup"; + type OutliningSpans = "outliningSpans"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + type NameOrDottedNameSpan = "nameOrDottedNameSpan"; + type BreakpointStatement = "breakpointStatement"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetCodeFixesFull = "getCodeFixes-full"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; + } + interface Message { + seq: number; + type: "request" | "response" | "event"; + } + interface Request extends Message { + command: string; + arguments?: any; + } + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; + } + interface Event extends Message { + event: string; + body?: any; + } + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; + } + interface FileRequestArgs { + file: string; + projectFileName?: string; + } + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; + } + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; + } + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; + } + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; + } + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; + } + interface OutliningSpansRequest extends FileRequest { + command: CommandTypes.OutliningSpans; + } + interface OutliningSpansResponse extends Response { + body?: OutliningSpan[]; + } + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; + } + interface IndentationResponse extends Response { + body?: IndentationResult; + } + interface IndentationResult { + position: number; + indentation: number; + } + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; + } + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; + } + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; + } + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; + } + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; + } + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + interface FileLocationRequestArgs extends FileRequestArgs { + line: number; + offset: number; + position?: number; + } + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + startPosition?: number; + endLine: number; + endOffset: number; + endPosition?: number; + errorCodes?: number[]; + } + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; + } + interface EncodedSemanticClassificationsRequest extends FileRequest { + arguments: EncodedSemanticClassificationsRequestArgs; + } + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; + } + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; + } + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + interface Location { + line: number; + offset: number; + } + interface TextSpan { + start: Location; + end: Location; + } + interface FileSpan extends TextSpan { + file: string; + } + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; + } + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + interface HighlightSpan extends TextSpan { + kind: string; + } + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; + } + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; + } + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + interface RenameRequestArgs extends FileLocationRequestArgs { + findInComments?: boolean; + findInStrings?: boolean; + } + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage?: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + } + interface SpanGroup { + file: string; + locs: TextSpan[]; + } + interface RenameResponseBody { + info: RenameInfo; + locs: SpanGroup[]; + } + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + interface ExternalFile { + fileName: string; + scriptKind?: ScriptKindName | ts.ScriptKind; + hasMixedContent?: boolean; + content?: string; + } + interface ExternalProject { + projectFileName: string; + rootFiles: ExternalFile[]; + options: ExternalProjectCompilerOptions; + typingOptions?: TypingOptions; + } + interface CompileOnSaveMixin { + compileOnSave?: boolean; + } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + interface ProjectVersionInfo { + projectName: string; + isInferred: boolean; + version: number; + options: ts.CompilerOptions; + } + interface ProjectChanges { + added: string[]; + removed: string[]; + } + interface ProjectFiles { + info?: ProjectVersionInfo; + files?: string[]; + changes?: ProjectChanges; + } + interface ProjectFilesWithDiagnostics extends ProjectFiles { + projectErrors: DiagnosticWithLinePosition[]; + } + interface ChangedOpenFile { + fileName: string; + changes: ts.TextChange[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; + } + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; + } + interface ConfigureResponse extends Response { + } + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: ScriptKindName; + } + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; + } + interface OpenExternalProjectResponse extends Response { + } + interface OpenExternalProjectsResponse extends Response { + } + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + interface CloseExternalProjectRequestArgs { + projectFileName: string; + } + interface CloseExternalProjectResponse extends Response { + } + interface SynchronizeProjectListRequest extends Request { + arguments: SynchronizeProjectListRequestArgs; + } + interface SynchronizeProjectListRequestArgs { + knownProjects: protocol.ProjectVersionInfo[]; + } + interface ApplyChangedToOpenFilesRequest extends Request { + arguments: ApplyChangedToOpenFilesRequestArgs; + } + interface ApplyChangedToOpenFilesRequestArgs { + openFiles?: ExternalFile[]; + changedFiles?: ChangedOpenFile[]; + closedFiles?: string[]; + } + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; + } + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + interface CompileOnSaveAffectedFileListSingleProject { + projectFileName: string; + fileNames: string[]; + } + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + forced?: boolean; + } + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + interface QuickInfoResponseBody { + kind: string; + kindModifiers: string; + start: Location; + end: Location; + displayString: string; + documentation: string; + } + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + interface FormatRequestArgs extends FileLocationRequestArgs { + endLine: number; + endOffset: number; + endPosition?: number; + options?: FormatCodeSettings; + } + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + interface CodeEdit { + start: Location; + end: Location; + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + body?: CodeAction[]; + } + interface CodeAction { + description: string; + changes: FileCodeEdits[]; + } + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; + } + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; + } + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; + } + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface GeterrForProjectRequestArgs { + file: string; + delay: number; + } + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + interface GeterrRequestArgs { + files: string[]; + delay: number; + } + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; + } + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; + } + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; + diagnostics: Diagnostic[]; + } + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; + } + interface ReloadResponse extends Response { + } + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; + } + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; + } + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; + } + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + interface BraceResponse extends Response { + body?: TextSpan[]; + } + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; + } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + type TelemetryEventName = "telemetry"; + interface TelemetryEvent extends Event { + event: TelemetryEventName; + body: TelemetryEventBody; + } + interface TelemetryEventBody { + telemetryEventName: string; + payload: any; + } + type TypingsInstalledTelemetryEventName = "typingsInstalled"; + interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { + telemetryEventName: TypingsInstalledTelemetryEventName; + payload: TypingsInstalledTelemetryEventPayload; + } + interface TypingsInstalledTelemetryEventPayload { + installedPackages: string; + installSuccess: boolean; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; + } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; +} declare namespace ts { interface MapLike { [index: string]: T; @@ -165,170 +985,177 @@ 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, + MappedType = 170, + LiteralType = 171, + ObjectBindingPattern = 172, + ArrayBindingPattern = 173, + BindingElement = 174, + ArrayLiteralExpression = 175, + ObjectLiteralExpression = 176, + PropertyAccessExpression = 177, + ElementAccessExpression = 178, + CallExpression = 179, + NewExpression = 180, + TaggedTemplateExpression = 181, + TypeAssertionExpression = 182, + ParenthesizedExpression = 183, + FunctionExpression = 184, + ArrowFunction = 185, + DeleteExpression = 186, + TypeOfExpression = 187, + VoidExpression = 188, + AwaitExpression = 189, + PrefixUnaryExpression = 190, + PostfixUnaryExpression = 191, + BinaryExpression = 192, + ConditionalExpression = 193, + TemplateExpression = 194, + YieldExpression = 195, + SpreadElement = 196, + ClassExpression = 197, + OmittedExpression = 198, + ExpressionWithTypeArguments = 199, + AsExpression = 200, + NonNullExpression = 201, + TemplateSpan = 202, + SemicolonClassElement = 203, + Block = 204, + VariableStatement = 205, + EmptyStatement = 206, + ExpressionStatement = 207, + IfStatement = 208, + DoStatement = 209, + WhileStatement = 210, + ForStatement = 211, + ForInStatement = 212, + ForOfStatement = 213, + ContinueStatement = 214, + BreakStatement = 215, + ReturnStatement = 216, + WithStatement = 217, + SwitchStatement = 218, + LabeledStatement = 219, + ThrowStatement = 220, + TryStatement = 221, + DebuggerStatement = 222, + VariableDeclaration = 223, + VariableDeclarationList = 224, + FunctionDeclaration = 225, + ClassDeclaration = 226, + InterfaceDeclaration = 227, + TypeAliasDeclaration = 228, + EnumDeclaration = 229, + ModuleDeclaration = 230, + ModuleBlock = 231, + CaseBlock = 232, + NamespaceExportDeclaration = 233, + ImportEqualsDeclaration = 234, + ImportDeclaration = 235, + ImportClause = 236, + NamespaceImport = 237, + NamedImports = 238, + ImportSpecifier = 239, + ExportAssignment = 240, + ExportDeclaration = 241, + NamedExports = 242, + ExportSpecifier = 243, + MissingDeclaration = 244, + ExternalModuleReference = 245, + JsxElement = 246, + JsxSelfClosingElement = 247, + JsxOpeningElement = 248, + JsxClosingElement = 249, + JsxAttribute = 250, + JsxSpreadAttribute = 251, + JsxExpression = 252, + CaseClause = 253, + DefaultClause = 254, + HeritageClause = 255, + CatchClause = 256, + PropertyAssignment = 257, + ShorthandPropertyAssignment = 258, + SpreadAssignment = 259, + EnumMember = 260, + SourceFile = 261, + JSDocTypeExpression = 262, + JSDocAllType = 263, + JSDocUnknownType = 264, + JSDocArrayType = 265, + JSDocUnionType = 266, + JSDocTupleType = 267, + JSDocNullableType = 268, + JSDocNonNullableType = 269, + JSDocRecordType = 270, + JSDocRecordMember = 271, + JSDocTypeReference = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocConstructorType = 276, + JSDocThisType = 277, + JSDocComment = 278, + JSDocTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + JSDocLiteralType = 287, + JSDocNullKeyword = 288, + JSDocUndefinedKeyword = 289, + JSDocNeverKeyword = 290, + SyntaxList = 291, + NotEmittedStatement = 292, + PartiallyEmittedExpression = 293, + MergeDeclarationMarker = 294, + EndOfDeclarationMarker = 295, + Count = 296, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -336,15 +1163,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 = 171, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 139, + LastToken = 140, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -353,11 +1180,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 140, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + FirstNode = 141, + FirstJSDocNode = 262, + LastJSDocNode = 287, + FirstJSDocTagNode = 278, + LastJSDocTagNode = 290, } const enum NodeFlags { None = 0, @@ -375,21 +1202,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, @@ -409,6 +1237,7 @@ declare namespace ts { ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, + ExportDefault = 513, } const enum JsxFlags { None = 0, @@ -416,12 +1245,29 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3, } + const enum RelationComparisonResult { + Succeeded = 1, + Failed = 2, + FailedAndReported = 3, + } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; + modifierFlagsCache?: ModifierFlags; + transformFlags?: TransformFlags; decorators?: NodeArray; modifiers?: ModifiersArray; + id?: number; parent?: Node; + original?: Node; + startsOnNewLine?: boolean; + jsDocComments?: JSDoc[]; + symbol?: Symbol; + locals?: SymbolTable; + nextContainer?: Node; + localSymbol?: Symbol; + flowNode?: FlowNode; + emitNode?: EmitNode; } interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; @@ -437,16 +1283,30 @@ declare namespace ts { type EqualsGreaterThanToken = Token; type EndOfFileToken = Token; type AtToken = Token; + type ReadonlyToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; + const enum GeneratedIdentifierKind { + None = 0, + Auto = 1, + Loop = 2, + Unique = 3, + Node = 4, + } interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; + autoGenerateKind?: GeneratedIdentifierKind; + autoGenerateId?: number; + isInJSDocNamespace?: boolean; } 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; @@ -533,7 +1393,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; @@ -547,6 +1407,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; @@ -669,12 +1533,30 @@ 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 MappedTypeNode extends TypeNode, Declaration { + kind: SyntaxKind.MappedType; + readonlyToken?: ReadonlyToken; + typeParameter: TypeParameterDeclaration; + questionToken?: QuestionToken; + type?: TypeNode; + } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: Expression; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; + textSourceNode?: Identifier | StringLiteral; } interface Expression extends Node { _expressionBrand: any; @@ -683,6 +1565,10 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } + interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; + expression: Expression; + } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -701,9 +1587,6 @@ declare namespace ts { operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } @@ -772,6 +1655,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; @@ -796,6 +1690,7 @@ declare namespace ts { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; + isOctalLiteral?: boolean; } interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; @@ -837,9 +1732,10 @@ declare namespace ts { interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; 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 { @@ -847,6 +1743,7 @@ declare namespace ts { } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; + multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; @@ -955,6 +1852,15 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } + 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; } @@ -969,6 +1875,7 @@ declare namespace ts { interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; + multiLine?: boolean; } interface VariableStatement extends Statement { kind: SyntaxKind.VariableStatement; @@ -1126,12 +2033,16 @@ declare namespace ts { interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | LiteralExpression; - body?: ModuleBlock | NamespaceDeclaration; + body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; } interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: ModuleBlock | NamespaceDeclaration; } + interface JSDocNamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: JSDocNamespaceDeclaration | Identifier; + } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; statements: NodeArray; @@ -1303,6 +2214,7 @@ declare namespace ts { } interface JSDocTypedefTag extends JSDocTag, Declaration { kind: SyntaxKind.JSDocTypedefTag; + fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression; jsDocTypeLiteral?: JSDocTypeLiteral; @@ -1390,8 +2302,28 @@ declare namespace ts { typeReferenceDirectives: FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; + renamedDependencies?: Map; hasNoDefaultLib: boolean; languageVersion: ScriptTarget; + scriptKind: ScriptKind; + externalModuleIndicator: Node; + commonJsModuleIndicator: Node; + identifiers: Map; + nodeCount: number; + identifierCount: number; + symbolCount: number; + parseDiagnostics: Diagnostic[]; + additionalSyntacticDiagnostics?: Diagnostic[]; + bindDiagnostics: Diagnostic[]; + lineMap: number[]; + classifiableNames?: Map; + resolvedModules: Map; + resolvedTypeReferenceDirectiveNames: Map; + imports: LiteralExpression[]; + moduleAugmentations: LiteralExpression[]; + patternAmbientModules?: PatternAmbientModule[]; + ambientModuleNames: string[]; + externalHelpersModuleName?: Identifier; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1424,6 +2356,18 @@ declare namespace ts { getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getTypeChecker(): TypeChecker; + getCommonSourceDirectory(): string; + getDiagnosticsProducingTypeChecker(): TypeChecker; + dropDiagnosticsProducingTypeChecker(): void; + getClassifiableNames(): Map; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getFileProcessingDiagnostics(): DiagnosticCollection; + getResolvedTypeReferenceDirectives(): Map; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; + structureIsReused?: boolean; } interface SourceMapSpan { emittedLine: number; @@ -1454,6 +2398,13 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; emittedFiles: string[]; + sourceMaps: SourceMapData[]; + } + interface TypeCheckerHost { + getCompilerOptions(): CompilerOptions; + getSourceFiles(): SourceFile[]; + getSourceFile(fileName: string): SourceFile; + getResolvedTypeReferenceDirectives(): Map; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -1493,6 +2444,14 @@ 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; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1540,6 +2499,15 @@ declare namespace ts { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } + const enum SymbolAccessibility { + Accessible = 0, + NotAccessible = 1, + CannotBeNamed = 2, + } + const enum SyntheticSymbolKind { + UnionOrIntersection = 0, + Spread = 1, + } const enum TypePredicateKind { This = 0, Identifier = 1, @@ -1557,6 +2525,61 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; + interface SymbolVisibilityResult { + accessibility: SymbolAccessibility; + aliasesToMakeVisible?: AnyImportSyntax[]; + errorSymbolName?: string; + errorNode?: Node; + } + interface SymbolAccessibilityResult extends SymbolVisibilityResult { + errorModuleName?: string; + } + enum TypeReferenceSerializationKind { + Unknown = 0, + TypeWithConstructSignatureAndValue = 1, + VoidNullableOrNeverType = 2, + NumberLikeType = 3, + StringLikeType = 4, + BooleanType = 5, + ArrayLikeType = 6, + ESSymbolType = 7, + Promise = 8, + TypeWithCallSignature = 9, + ObjectType = 10, + } + interface EmitResolver { + hasGlobalName(name: string): boolean; + getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration; + getReferencedImportDeclaration(node: Identifier): Declaration; + getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; + isDeclarationWithCollidingName(node: Declaration): boolean; + isValueAliasDeclaration(node: Node): boolean; + isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; + isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; + getNodeCheckFlags(node: Node): NodeCheckFlags; + isDeclarationVisible(node: Declaration): boolean; + collectLinkedAliases(node: Identifier): Node[]; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; + isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; + isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; + getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; + getReferencedValueDeclaration(reference: Identifier): Declaration; + getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; + isOptionalParameter(node: ParameterDeclaration): boolean; + moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; + isArgumentsLocalBinding(node: Identifier): boolean; + getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; + getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; + 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, FunctionScopedVariable = 1, @@ -1623,6 +2646,7 @@ declare namespace ts { PropertyOrAccessor = 98308, Export = 7340032, ClassMember = 106500, + Classifiable = 788448, } interface Symbol { flags: SymbolFlags; @@ -1632,8 +2656,86 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; + isReadonly?: boolean; + id?: number; + mergeId?: number; + parent?: Symbol; + exportSymbol?: Symbol; + constEnumOnlyModule?: boolean; + isReferenced?: boolean; + isReplaceableByMethod?: boolean; + isAssigned?: boolean; + } + interface SymbolLinks { + target?: Symbol; + type?: Type; + declaredType?: Type; + typeParameters?: TypeParameter[]; + inferredClassType?: Type; + instantiations?: Map; + mapper?: TypeMapper; + referenced?: boolean; + containingType?: UnionOrIntersectionType; + leftSpread?: Symbol; + rightSpread?: Symbol; + hasNonUniformType?: boolean; + isPartial?: boolean; + isDiscriminantProperty?: boolean; + resolvedExports?: SymbolTable; + exportsChecked?: boolean; + isDeclarationWithCollidingName?: boolean; + bindingElement?: BindingElement; + exportsSomeValue?: boolean; + } + interface TransientSymbol extends Symbol, SymbolLinks { } type SymbolTable = Map; + interface Pattern { + prefix: string; + suffix: string; + } + interface PatternAmbientModule { + pattern: Pattern; + symbol: Symbol; + } + const enum NodeCheckFlags { + TypeChecked = 1, + LexicalThis = 2, + CaptureThis = 4, + SuperInstance = 256, + SuperStatic = 512, + ContextChecked = 1024, + AsyncMethodWithSuper = 2048, + AsyncMethodWithSuperBinding = 4096, + CaptureArguments = 8192, + EnumValuesComputed = 16384, + LexicalModuleMergesWithClass = 32768, + LoopWithCapturedBlockScopedBinding = 65536, + CapturedBlockScopedBinding = 131072, + BlockScopedBindingInLoop = 262144, + ClassWithBodyScopedClassBinding = 524288, + BodyScopedClassBinding = 1048576, + NeedsLoopOutParameter = 2097152, + AssignmentsMarked = 4194304, + ClassWithConstructorReference = 8388608, + ConstructorReferenceInClass = 16777216, + } + interface NodeLinks { + flags?: NodeCheckFlags; + resolvedType?: Type; + resolvedSignature?: Signature; + resolvedSymbol?: Symbol; + resolvedIndexInfo?: IndexInfo; + maybeTypePredicate?: boolean; + enumMemberValue?: number; + isVisible?: boolean; + hasReportedStatementInAmbientContext?: boolean; + jsxFlags?: JsxFlags; + resolvedJsxType?: Type; + hasSuperCall?: boolean; + superCall?: ExpressionStatement; + switchTypes?: Type[]; + } const enum TypeFlags { Any = 1, String = 2, @@ -1650,36 +2752,46 @@ declare namespace ts { Null = 4096, Never = 8192, TypeParameter = 16384, - Class = 32768, - Interface = 65536, - Reference = 131072, - Tuple = 262144, - Union = 524288, - Intersection = 1048576, - Anonymous = 2097152, - Instantiated = 4194304, + Object = 32768, + Union = 65536, + Intersection = 131072, + Index = 262144, + IndexedAccess = 524288, + FreshLiteral = 1048576, + ContainsWideningType = 2097152, + ContainsObjectLiteral = 4194304, + ContainsAnyFunctionType = 8388608, + Nullable = 6144, Literal = 480, StringOrNumberLiteral = 96, + DefinitelyFalsy = 7392, PossiblyFalsy = 7406, + Intrinsic = 16015, + Primitive = 8190, StringLike = 34, NumberLike = 340, BooleanLike = 136, EnumLike = 272, - ObjectType = 2588672, - UnionOrIntersection = 1572864, - StructuredType = 4161536, - StructuredOrTypeParameter = 4177920, - Narrowable = 4178943, - NotUnionOrUnit = 2589185, + UnionOrIntersection = 196608, + StructuredType = 229376, + StructuredOrTypeParameter = 507904, + Narrowable = 1033215, + NotUnionOrUnit = 33281, + RequiresWidening = 6291456, + PropagatingFlags = 14680064, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; + id: number; symbol?: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } + interface IntrinsicType extends Type { + intrinsicName: string; + } interface LiteralType extends Type { text: string; freshType?: LiteralType; @@ -1691,14 +2803,29 @@ declare namespace ts { interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; } + const enum ObjectFlags { + Class = 1, + Interface = 2, + Reference = 4, + Tuple = 8, + Anonymous = 16, + Mapped = 32, + Instantiated = 64, + ObjectLiteral = 128, + EvolvingArray = 256, + ObjectLiteralPatternWithComputedProperties = 512, + ClassOrInterface = 3, + } interface ObjectType extends Type { - isObjectLiteralPatternWithComputedProperties?: boolean; + objectFlags: ObjectFlags; } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; + resolvedBaseConstructorType?: Type; + resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1712,16 +2839,63 @@ declare namespace ts { typeArguments: Type[]; } interface GenericType extends InterfaceType, TypeReference { + instantiations: Map; } interface UnionOrIntersectionType extends Type { types: Type[]; + resolvedProperties: SymbolTable; + couldContainTypeParameters: boolean; } interface UnionType extends UnionOrIntersectionType { } interface IntersectionType extends UnionOrIntersectionType { } + type StructuredType = ObjectType | UnionType | IntersectionType; + interface AnonymousType extends ObjectType { + target?: AnonymousType; + mapper?: TypeMapper; + } + interface MappedType extends ObjectType { + declaration: MappedTypeNode; + typeParameter?: TypeParameter; + constraintType?: Type; + templateType?: Type; + mapper?: TypeMapper; + } + interface EvolvingArrayType extends ObjectType { + elementType: Type; + finalArrayType?: Type; + } + interface ResolvedType extends ObjectType, UnionOrIntersectionType { + members: SymbolTable; + properties: Symbol[]; + callSignatures: Signature[]; + constructSignatures: Signature[]; + stringIndexInfo?: IndexInfo; + numberIndexInfo?: IndexInfo; + } + interface FreshObjectLiteralType extends ResolvedType { + regularType: ResolvedType; + } + interface IterableOrIteratorType extends ObjectType, UnionType { + iterableElementType?: Type; + iteratorElementType?: Type; + } interface TypeParameter extends Type { constraint: Type; + 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, @@ -1731,6 +2905,18 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; + thisParameter?: Symbol; + resolvedReturnType: Type; + minArgumentCount: number; + hasRestParameter: boolean; + hasLiteralTypes: boolean; + target?: Signature; + mapper?: TypeMapper; + unionSignatures?: Signature[]; + erasedSignatureCache?: Signature; + isolatedSignatureType?: ObjectType; + typePredicate?: TypePredicate; + instantiations?: Map; } const enum IndexKind { String = 0, @@ -1741,6 +2927,33 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } + interface TypeMapper { + (t: TypeParameter): Type; + mappedTypes?: Type[]; + instantiations?: Type[]; + context?: InferenceContext; + } + interface TypeInferences { + primary: Type[]; + secondary: Type[]; + topLevel: boolean; + isFixed: boolean; + } + interface InferenceContext { + signature: Signature; + inferUnionTypes: boolean; + inferences: TypeInferences[]; + inferredTypes: Type[]; + mapper?: TypeMapper; + failedTypeParameterIndex?: number; + } + const enum SpecialPropertyAssignmentKind { + None = 0, + ExportsProperty = 1, + ModuleExports = 2, + PrototypeProperty = 3, + ThisProperty = 4, + } interface DiagnosticMessage { key: string; category: DiagnosticCategory; @@ -1773,25 +2986,33 @@ declare namespace ts { type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; + allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; charset?: string; + configFilePath?: string; declaration?: boolean; declarationDir?: string; + diagnostics?: boolean; + extendedDiagnostics?: boolean; disableSizeLimit?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; + help?: boolean; importHelpers?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; lib?: string[]; + listEmittedFiles?: boolean; + listFiles?: boolean; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; @@ -1799,6 +3020,7 @@ declare namespace ts { moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; + noEmitForJsFiles?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; @@ -1817,7 +3039,9 @@ declare namespace ts { paths?: MapLike; preserveConstEnums?: boolean; project?: string; + pretty?: DiagnosticStyle; reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -1826,12 +3050,16 @@ declare namespace ts { sourceMap?: boolean; sourceRoot?: string; strictNullChecks?: boolean; + stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + suppressOutputPathCheck?: boolean; target?: ScriptTarget; traceResolution?: boolean; types?: string[]; typeRoots?: string[]; + version?: boolean; + watch?: boolean; [option: string]: CompilerOptionsValue | undefined; } interface TypingOptions { @@ -1847,6 +3075,7 @@ declare namespace ts { packageNameToTypingLocation: Map; typingOptions: TypingOptions; compilerOptions: CompilerOptions; + unresolvedImports: ReadonlyArray; } enum ModuleKind { None = 0, @@ -1882,12 +3111,17 @@ declare namespace ts { ES2015 = 2, ES2016 = 3, ES2017 = 4, - Latest = 4, + ESNext = 5, + Latest = 5, } const enum LanguageVariant { Standard = 0, JSX = 1, } + const enum DiagnosticStyle { + Simple = 0, + Pretty = 1, + } interface ParsedCommandLine { options: CompilerOptions; typingOptions?: TypingOptions; @@ -1905,6 +3139,156 @@ declare namespace ts { fileNames: string[]; wildcardDirectories: MapLike; } + interface CommandLineOptionBase { + name: string; + type: "string" | "number" | "boolean" | "object" | "list" | Map; + isFilePath?: boolean; + shortName?: string; + description?: DiagnosticMessage; + paramType?: DiagnosticMessage; + experimental?: boolean; + isTSConfigOnly?: boolean; + } + interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { + type: "string" | "number" | "boolean"; + } + interface CommandLineOptionOfCustomType extends CommandLineOptionBase { + type: Map; + } + interface TsConfigOnlyOption extends CommandLineOptionBase { + type: "object"; + } + interface CommandLineOptionOfListType extends CommandLineOptionBase { + type: "list"; + element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; + } + type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; + const enum CharacterCodes { + nullCharacter = 0, + maxAsciiCharacter = 127, + lineFeed = 10, + carriageReturn = 13, + lineSeparator = 8232, + paragraphSeparator = 8233, + nextLine = 133, + space = 32, + nonBreakingSpace = 160, + enQuad = 8192, + emQuad = 8193, + enSpace = 8194, + emSpace = 8195, + threePerEmSpace = 8196, + fourPerEmSpace = 8197, + sixPerEmSpace = 8198, + figureSpace = 8199, + punctuationSpace = 8200, + thinSpace = 8201, + hairSpace = 8202, + zeroWidthSpace = 8203, + narrowNoBreakSpace = 8239, + ideographicSpace = 12288, + mathematicalSpace = 8287, + ogham = 5760, + _ = 95, + $ = 36, + _0 = 48, + _1 = 49, + _2 = 50, + _3 = 51, + _4 = 52, + _5 = 53, + _6 = 54, + _7 = 55, + _8 = 56, + _9 = 57, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + ampersand = 38, + asterisk = 42, + at = 64, + backslash = 92, + backtick = 96, + bar = 124, + caret = 94, + closeBrace = 125, + closeBracket = 93, + closeParen = 41, + colon = 58, + comma = 44, + dot = 46, + doubleQuote = 34, + equals = 61, + exclamation = 33, + greaterThan = 62, + hash = 35, + lessThan = 60, + minus = 45, + openBrace = 123, + openBracket = 91, + openParen = 40, + percent = 37, + plus = 43, + question = 63, + semicolon = 59, + singleQuote = 39, + slash = 47, + tilde = 126, + backspace = 8, + formFeed = 12, + byteOrderMark = 65279, + tab = 9, + verticalTab = 11, + } interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; @@ -1918,8 +3302,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 { @@ -1946,6 +3341,110 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } + const enum TransformFlags { + None = 0, + TypeScript = 1, + ContainsTypeScript = 2, + Jsx = 4, + ContainsJsx = 8, + 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, + 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 = 554784085, + ArrayLiteralOrCallOrNewExcludes = 545281365, + VariableDeclarationListExcludes = 604001621, + ParameterExcludes = 604001621, + TypeScriptClassSyntaxMask = 4390912, + ES2015FunctionSyntaxMask = 2621440, + } + interface EmitNode { + flags?: EmitFlags; + commentRange?: TextRange; + sourceMapRange?: TextRange; + tokenSourceMapRanges?: Map; + annotatedNodes?: Node[]; + constantValue?: number; + } + const enum EmitFlags { + EmitEmitHelpers = 1, + EmitExportStar = 2, + EmitSuperHelper = 4, + EmitAdvancedSuperHelper = 8, + UMDDefine = 16, + SingleLine = 32, + AdviseOnEmitNode = 64, + NoSubstitution = 128, + CapturesThis = 256, + NoLeadingSourceMap = 512, + NoTrailingSourceMap = 1024, + NoSourceMap = 1536, + NoNestedSourceMaps = 2048, + NoTokenLeadingSourceMaps = 4096, + NoTokenTrailingSourceMaps = 8192, + NoTokenSourceMaps = 12288, + NoLeadingComments = 16384, + NoTrailingComments = 32768, + NoComments = 49152, + NoNestedComments = 65536, + ExportName = 131072, + LocalName = 262144, + Indented = 524288, + NoIndentation = 1048576, + AsyncFunctionBody = 2097152, + ReuseTempVariableScope = 4194304, + CustomPrologue = 8388608, + NoHoisting = 16777216, + HasEndOfDeclarationMarker = 33554432, + } + const enum EmitContext { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } + interface LexicalEnvironment { + startLexicalEnvironment(): void; + endLexicalEnvironment(): Statement[]; + } interface TextSpan { start: number; length: number; @@ -1954,10 +3453,229 @@ declare namespace ts { span: TextSpan; newLength: number; } + interface DiagnosticCollection { + add(diagnostic: Diagnostic): void; + getGlobalDiagnostics(): Diagnostic[]; + getDiagnostics(fileName?: string): Diagnostic[]; + getModificationCount(): number; + reattachFileDiagnostics(newFile: SourceFile): void; + } interface SyntaxList extends Node { _children: Node[]; } } +declare namespace ts { + const timestamp: () => number; +} +declare namespace ts.performance { + function mark(markName: string): void; + function measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + function getCount(markName: string): number; + function getDuration(measureName: string): number; + function forEachMeasure(cb: (measureName: string, duration: number) => void): void; + function enable(): void; + function disable(): void; +} +declare namespace ts { + const enum Ternary { + False = 0, + Maybe = 1, + True = -1, + } + const collator: { + compare(a: string, b: string): number; + }; + function createMap(template?: MapLike): Map; + function createFileMap(keyMapper?: (key: string) => string): FileMap; + function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path; + const enum Comparison { + LessThan = -1, + EqualTo = 0, + 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; + function contains(array: T[], value: T): boolean; + function indexOf(array: T[], value: T): number; + function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number; + function countWhere(array: T[], predicate: (x: T, i: number) => boolean): number; + function filter(array: T[], f: (x: T) => x is U): U[]; + function filter(array: T[], f: (x: T) => boolean): T[]; + function removeWhere(array: T[], f: (x: T) => boolean): boolean; + function filterMutate(array: T[], f: (x: T) => boolean): void; + function map(array: T[], f: (x: T, i: number) => U): U[]; + function sameMap(array: T[], f: (x: T, i: number) => T): T[]; + function flatten(array: (T | T[])[]): T[]; + function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[]; + function span(array: T[], f: (x: T, i: number) => boolean): [T[], T[]]; + function spanMap(array: T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[]; + function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike; + function some(array: T[], predicate?: (value: T) => boolean): boolean; + function concatenate(array1: T[], array2: T[]): T[]; + function deduplicate(array: T[], areEqual?: (a: T, b: T) => boolean): T[]; + 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 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 replaceElement(array: T[], index: number, value: T): T[]; + 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; + function reduceRight(array: T[], f: (memo: T, value: T, i: number) => T): T; + function hasProperty(map: MapLike, key: string): boolean; + function getProperty(map: MapLike, key: string): T | undefined; + function getOwnKeys(map: MapLike): string[]; + function forEachProperty(map: Map, callback: (value: T, key: string) => U): U; + function someProperties(map: Map, predicate?: (value: T, key: string) => boolean): boolean; + function copyProperties(source: Map, target: MapLike): void; + function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; + function assign, T2>(t: T1, arg1: T2): T1 & T2; + function assign>(t: T1, ...args: any[]): any; + function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; + function reduceOwnProperties(map: MapLike, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; + function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean): boolean; + function arrayToMap(array: T[], makeKey: (value: T) => string): Map; + function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; + function isEmpty(map: Map): boolean; + function cloneMap(map: Map): Map; + function clone(object: T): T; + function extend(first: T1, second: T2): T1 & T2; + 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; + function notImplemented(): never; + function memoize(callback: () => T): () => T; + function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; + function compose(...args: ((t: T) => T)[]): (t: T) => T; + let localizedDiagnosticMessages: Map; + function getLocaleSpecificMessage(message: DiagnosticMessage): string; + function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; + function formatMessage(_dummy: any, message: DiagnosticMessage): string; + function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; + function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic; + function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; + function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; + function compareValues(a: T, b: T): Comparison; + function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison; + function compareStringsCaseInsensitive(a: string, b: string): Comparison; + function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; + function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; + function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; + function normalizeSlashes(path: string): string; + function getRootLength(path: string): number; + const directorySeparator = "/"; + function normalizePath(path: string): string; + function pathEndsWithDirectorySeparator(path: string): boolean; + function getDirectoryPath(path: Path): Path; + function getDirectoryPath(path: string): string; + function isUrl(path: string): boolean; + function isExternalModuleNameRelative(moduleName: string): boolean; + function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; + function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; + function hasZeroOrOneAsteriskCharacter(str: string): boolean; + function isRootedDiskPath(path: string): boolean; + function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; + function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; + function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string; + function getNormalizedPathFromPathComponents(pathComponents: string[]): string; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; + function getBaseFileName(path: string): string; + function combinePaths(path1: string, path2: string): string; + function removeTrailingDirectorySeparator(path: string): string; + function ensureTrailingDirectorySeparator(path: string): string; + function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; + 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[]; + } + interface FileMatcherPatterns { + includeFilePattern: string; + includeDirectoryPattern: string; + excludePattern: string; + basePaths: string[]; + } + function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns; + function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[]; + function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind; + function getScriptKindFromFileName(fileName: string): ScriptKind; + const supportedTypeScriptExtensions: string[]; + const supportedTypescriptExtensionsForExtractExtension: string[]; + const supportedJavascriptExtensions: string[]; + function getSupportedExtensions(options?: CompilerOptions): string[]; + function hasJavaScriptFileExtension(fileName: string): boolean; + function hasTypeScriptFileExtension(fileName: string): boolean; + function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions): boolean; + const enum ExtensionPriority { + TypeScriptFiles = 0, + DeclarationAndJavaScriptFiles = 2, + Limit = 5, + Highest = 0, + Lowest = 2, + } + function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority; + function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; + function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; + function removeFileExtension(path: string): string; + function tryRemoveExtension(path: string, extension: string): string | undefined; + function removeExtension(path: string, extension: string): string; + function changeExtension(path: T, newExtension: string): T; + interface ObjectAllocator { + getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; + getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; + getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier; + getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile; + getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; + getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; + getSignatureConstructor(): new (checker: TypeChecker) => Signature; + } + let objectAllocator: ObjectAllocator; + const enum AssertionLevel { + None = 0, + Normal = 1, + Aggressive = 2, + VeryAggressive = 3, + } + namespace Debug { + let currentAssertionLevel: AssertionLevel; + function shouldAssert(level: AssertionLevel): boolean; + function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; + function fail(message?: string): void; + } + function orderedRemoveItemAt(array: T[], index: number): void; + function unorderedRemoveItemAt(array: T[], index: number): void; + function unorderedRemoveItem(array: T[], item: T): void; + function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string; + function matchPatternOrExact(patternStrings: string[], candidate: string): string | Pattern | undefined; + function patternText({prefix, suffix}: Pattern): string; + function matchedText(pattern: Pattern, candidate: string): string; + 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; + function tryGetExtensionFromPath(path: string): Extension | undefined; +} declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -1974,7 +3692,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; @@ -1989,6 +3707,10 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; + getEnvironmentVariable(name: string): string; + tryEnableSourceMapsForHost?(): void; + setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout?(timeoutId: any): void; } interface FileWatcher { close(): void; @@ -2000,45 +3722,4790 @@ declare namespace ts { let sys: System; } declare namespace ts { - 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 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 classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; -} -declare namespace ts { - function getDefaultLibFileName(options: CompilerOptions): string; - function textSpanEnd(span: TextSpan): number; - function textSpanIsEmpty(span: TextSpan): boolean; - function textSpanContainsPosition(span: TextSpan, position: number): boolean; - function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; - function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; - function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; - function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; - function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; - function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; - function createTextSpan(start: number, length: number): TextSpan; - function createTextSpanFromBounds(start: number, end: number): TextSpan; - function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; - function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; - function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; - let unchangedTextChangeRange: TextChangeRange; - function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; - function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; - function getCombinedNodeFlags(node: Node): NodeFlags; + const Diagnostics: { + Unterminated_string_literal: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Identifier_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_file_cannot_have_a_reference_to_itself: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Trailing_comma_not_allowed: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Asterisk_Slash_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unexpected_token: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_parameter_must_be_last_in_a_parameter_list: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_cannot_have_question_mark_and_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_required_parameter_cannot_follow_an_optional_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_cannot_have_a_rest_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_parameter_cannot_have_an_accessibility_modifier: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_parameter_cannot_have_a_question_mark: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_parameter_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_must_have_a_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_parameter_must_have_a_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_parameter_type_must_be_string_or_number: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Accessibility_modifier_already_seen: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_must_precede_1_modifier: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_already_seen: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_a_class_element: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_must_be_followed_by_an_argument_list_or_member_access: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_ambient_modules_can_use_quoted_names: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Statements_are_not_allowed_in_ambient_contexts: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Initializers_are_not_allowed_in_ambient_contexts: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_be_used_in_an_ambient_context: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_be_used_with_a_class_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_be_used_here: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_a_data_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_a_module_or_namespace_element: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_0_modifier_cannot_be_used_with_an_interface_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_parameter_cannot_be_optional: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_parameter_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_set_accessor_must_have_exactly_one_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_set_accessor_cannot_have_an_optional_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_set_accessor_parameter_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_set_accessor_cannot_have_rest_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_get_accessor_cannot_have_parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + 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; + message: string; + }; + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Operand_for_await_does_not_have_a_valid_callable_then_member: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enum_member_must_have_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_export_assignment_cannot_be_used_in_a_namespace: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_a_type_member: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_an_index_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_0_modifier_cannot_be_used_with_an_import_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_reference_directive_syntax: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_accessor_cannot_be_declared_in_an_ambient_context: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_a_constructor_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_appear_on_a_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameters_cannot_appear_on_a_constructor_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_annotation_cannot_appear_on_a_constructor_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_accessor_cannot_have_type_parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_set_accessor_cannot_have_a_return_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_signature_must_have_exactly_one_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_list_cannot_be_empty: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_list_cannot_be_empty: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_argument_list_cannot_be_empty: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_use_of_0_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + with_statements_are_not_allowed_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + delete_cannot_be_called_on_an_identifier_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Jump_target_cannot_cross_function_boundary: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_return_statement_can_only_be_used_within_a_function_body: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_label_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_export_assignment_cannot_have_modifiers: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Octal_literals_are_not_allowed_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_tuple_type_element_list_cannot_be_empty: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Variable_declaration_list_cannot_be_empty: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Digit_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Hexadecimal_digit_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unexpected_end_of_text: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_character: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Declaration_or_statement_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Statement_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + case_or_default_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_or_signature_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enum_member_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Variable_declaration_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Argument_expression_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_assignment_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_or_comma_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_declaration_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_declaration_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_argument_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + String_literal_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Line_break_not_permitted_here: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + or_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Declaration_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_declarations_in_a_namespace_cannot_reference_a_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_name_0_differs_from_already_included_file_name_1_only_in_casing: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + const_declarations_must_be_initialized: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + const_declarations_can_only_be_declared_inside_a_block: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + let_declarations_can_only_be_declared_inside_a_block: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unterminated_template_literal: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unterminated_regular_expression_literal: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_object_member_cannot_be_declared_optional: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_yield_expression_is_only_allowed_in_a_generator_body: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Computed_property_names_are_not_allowed_in_enums: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_comma_expression_is_not_allowed_in_a_computed_property_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + extends_clause_already_seen: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + extends_clause_must_precede_implements_clause: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Classes_can_only_extend_a_single_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + implements_clause_already_seen: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Interface_declaration_cannot_have_implements_clause: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Binary_digit_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Octal_digit_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unexpected_token_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_destructuring_pattern_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Array_element_destructuring_pattern_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_destructuring_declaration_must_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_implementation_cannot_be_declared_in_ambient_contexts: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Modifiers_cannot_appear_here: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Merge_conflict_marker_encountered: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_element_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_parameter_property_may_not_be_declared_using_a_binding_pattern: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_import_declaration_cannot_have_modifiers: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_has_no_default_export: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_export_declaration_cannot_have_modifiers: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Export_declarations_are_not_permitted_in_a_namespace: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Catch_clause_variable_cannot_have_a_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Catch_clause_variable_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unterminated_Unicode_escape_sequence: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Line_terminator_not_permitted_before_arrow: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Decorators_are_not_valid_here: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_class_declaration_without_the_default_modifier_must_have_a_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Export_assignment_is_not_supported_when_module_flag_is_system: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Generators_are_not_allowed_in_an_ambient_context: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_overload_signature_cannot_be_declared_as_a_generator: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_tag_already_specified: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Signature_0_must_have_a_type_predicate: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_parameter_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_predicate_0_is_not_assignable_to_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_is_not_in_the_same_position_as_parameter_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_type_predicate_cannot_reference_a_rest_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_export_assignment_can_only_be_used_in_a_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_import_declaration_can_only_be_used_in_a_namespace_or_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_export_declaration_can_only_be_used_in_a_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_modifier_cannot_be_used_with_1_modifier: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Abstract_methods_can_only_appear_within_an_abstract_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_interface_property_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_type_literal_property_cannot_have_an_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_class_member_cannot_have_the_0_keyword: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + with_statements_are_not_allowed_in_an_async_function_block: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + await_expression_is_only_allowed_within_an_async_function: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_body_of_an_if_statement_cannot_be_the_empty_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Global_module_exports_may_only_appear_in_module_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Global_module_exports_may_only_appear_in_declaration_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Global_module_exports_may_only_appear_at_top_level: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_parameter_property_cannot_be_declared_using_a_rest_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Static_members_cannot_reference_class_type_parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Circular_definition_of_import_alias_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_has_no_exported_member_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_0_is_not_a_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_module_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_recursively_references_itself_as_a_base_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_class_may_only_extend_another_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_interface_may_only_extend_a_class_or_another_interface: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_has_a_circular_constraint: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Generic_type_0_requires_1_type_argument_s: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_is_not_generic: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Global_type_0_must_be_a_class_or_interface_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Global_type_0_must_have_1_type_parameter_s: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_global_type_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Named_property_0_of_types_1_and_2_are_not_identical: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Interface_0_cannot_simultaneously_extend_types_1_and_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Excessive_stack_depth_comparing_types_0_and_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_is_not_assignable_to_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_redeclare_exported_variable_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_missing_in_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_private_in_type_1_but_not_in_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Types_of_property_0_are_incompatible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_optional_in_type_1_but_required_in_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Types_of_parameters_0_and_1_are_incompatible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Index_signature_is_missing_in_type_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Index_signatures_are_incompatible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + this_cannot_be_referenced_in_a_module_or_namespace_body: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + this_cannot_be_referenced_in_current_location: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + this_cannot_be_referenced_in_constructor_arguments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + this_cannot_be_referenced_in_a_static_property_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_can_only_be_referenced_in_a_derived_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_cannot_be_referenced_in_constructor_arguments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_does_not_exist_on_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_private_and_only_accessible_within_class_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_does_not_satisfy_the_constraint_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Supplied_parameters_do_not_match_any_signature_of_call_target: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Untyped_function_calls_may_not_accept_type_arguments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_a_void_function_can_be_called_with_the_new_keyword: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_cannot_be_converted_to_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Operator_0_cannot_be_applied_to_types_1_and_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_name_cannot_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_parameter_property_is_only_allowed_in_a_constructor_implementation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_parameter_must_be_of_an_array_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_cannot_be_referenced_in_its_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_string_index_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_number_index_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Constructors_for_derived_classes_must_contain_a_super_call: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_get_accessor_must_return_a_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Getter_and_setter_accessors_do_not_agree_in_visibility: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + get_and_set_accessor_must_have_the_same_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_signature_with_an_implementation_cannot_use_a_string_literal_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Overload_signatures_must_all_be_exported_or_non_exported: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Overload_signatures_must_all_be_ambient_or_non_ambient: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Overload_signatures_must_all_be_public_private_or_protected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Overload_signatures_must_all_be_optional_or_required: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_overload_must_be_static: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_overload_must_not_be_static: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_implementation_name_must_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Constructor_implementation_is_missing: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_implementation_is_missing_or_not_immediately_following_the_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Multiple_constructor_implementations_are_not_allowed: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_function_implementation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Overload_signature_is_not_compatible_with_function_implementation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Declaration_name_conflicts_with_built_in_global_identifier_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Setters_cannot_return_a_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_name_cannot_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_0_incorrectly_extends_base_class_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_static_side_0_incorrectly_extends_base_class_static_side_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_0_incorrectly_implements_interface_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_class_may_only_implement_another_class_or_interface: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Interface_name_cannot_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + All_declarations_of_0_must_have_identical_type_parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Interface_0_incorrectly_extends_interface_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enum_name_cannot_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Ambient_module_declaration_cannot_specify_relative_module_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_name_cannot_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_declaration_conflicts_with_local_declaration_of_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Types_have_separate_declarations_of_a_private_property_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_protected_in_type_1_but_public_in_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Block_scoped_variable_0_used_before_its_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_redeclare_block_scoped_variable_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_enum_member_cannot_have_a_numeric_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Variable_0_is_used_before_being_assigned: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_alias_0_circularly_references_itself: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_alias_name_cannot_be_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_AMD_module_cannot_have_multiple_name_assignments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_has_no_property_1_and_no_string_index_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_has_no_property_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_is_not_an_array_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_element_must_be_last_in_a_destructuring_pattern: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + this_cannot_be_referenced_in_a_computed_property_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_cannot_be_referenced_in_a_computed_property_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_global_value_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_0_operator_cannot_be_applied_to_type_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enum_declarations_must_all_be_const_or_non_const: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + In_const_enum_declarations_member_initializer_must_be_constant_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_const_enum_member_can_only_be_accessed_using_a_string_literal: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_does_not_exist_on_const_enum_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Export_declaration_conflicts_with_exported_declaration_of_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_iterator_must_have_a_next_method: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_redeclare_identifier_0_in_catch_clause: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_is_not_an_array_type_or_a_string_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_rest_element_cannot_contain_a_binding_pattern: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_namespace_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_generator_cannot_have_a_void_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_is_not_a_constructor_function_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + No_base_constructor_has_the_specified_number_of_type_arguments: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Base_constructor_return_type_0_is_not_a_class_or_interface_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Base_constructors_must_all_have_the_same_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_create_an_instance_of_the_abstract_class_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Overload_signatures_must_all_be_abstract_or_non_abstract: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Classes_containing_abstract_methods_must_be_marked_abstract: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + All_declarations_of_an_abstract_method_must_be_consecutive: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + yield_expressions_cannot_be_used_in_a_parameter_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + await_expressions_cannot_be_used_in_a_parameter_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_module_cannot_have_multiple_default_exports: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_incompatible_with_index_signature: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Object_is_possibly_null: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Object_is_possibly_undefined: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Object_is_possibly_null_or_undefined: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_function_returning_never_cannot_have_a_reachable_end_point: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enum_type_0_has_members_with_initializers_that_are_not_literals: { + code: number; + category: DiagnosticCategory; + 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; + key: string; + message: string; + }; + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_in_type_1_is_not_assignable_to_type_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_global_type_JSX_0_may_not_have_more_than_one_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_emit_namespaced_JSX_elements_in_React: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_expressions_must_have_one_parent_element: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_provides_no_match_for_the_signature_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_module_name_in_augmentation_module_0_cannot_be_found: { + code: number; + category: DiagnosticCategory; + 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; + key: string; + message: string; + }; + Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Accessors_must_both_be_abstract_or_non_abstract: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_is_not_comparable_to_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_this_parameter_must_be_the_first_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_constructor_cannot_have_a_this_parameter: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + get_and_set_accessor_must_have_the_same_this_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_this_types_of_each_signature_are_incompatible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + All_declarations_of_0_must_have_identical_modifiers: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_type_definition_file_for_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_extend_an_interface_0_Did_you_mean_implements: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_class_must_be_declared_after_its_base_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Namespace_0_has_no_exported_member_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { + code: number; + category: DiagnosticCategory; + 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; + }; + An_object_rest_element_must_be_an_identifier: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_declaration_0_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Exported_variable_0_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Public_property_0_of_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_of_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Return_type_of_exported_function_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_exported_function_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Exported_type_alias_0_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Default_export_of_the_module_has_or_is_using_private_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_current_host_does_not_support_the_0_option: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_the_common_subdirectory_path_for_the_input_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_read_file_0_Colon_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unsupported_file_encoding: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Failed_to_parse_file_0_Colon_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unknown_compiler_option_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Compiler_option_0_requires_a_value_of_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Could_not_write_file_0_Colon_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_0_cannot_be_specified_without_specifying_option_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_0_cannot_be_specified_with_option_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_tsconfig_json_file_is_already_defined_at_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_write_file_0_because_it_would_overwrite_input_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_specified_path_does_not_exist_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_paths_cannot_be_used_without_specifying_baseUrl_option: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Pattern_0_can_have_at_most_one_Asterisk_character: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Substitutions_for_pattern_0_should_be_an_array: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { + code: number; + category: DiagnosticCategory; + 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; + key: string; + message: string; + }; + Generates_corresponding_d_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Watch_input_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Redirect_output_structure_to_the_directory: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_erase_const_enum_declarations_in_generated_code: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_emit_outputs_if_any_errors_were_reported: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_emit_comments_to_output: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_emit_outputs: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Skip_type_checking_of_declaration_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Print_this_message: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Print_the_compiler_s_version: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Compile_the_project_in_the_given_directory: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Syntax_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + options: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Examples_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Options_Colon: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Version_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Insert_command_line_options_and_files_from_a_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_change_detected_Starting_incremental_compilation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + KIND: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + FILE: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + VERSION: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + LOCATION: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + DIRECTORY: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + STRATEGY: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Compilation_complete_Watching_for_file_changes: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Generates_corresponding_map_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Compiler_option_0_expects_an_argument: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unterminated_quoted_string_in_response_file_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Argument_for_0_option_must_be_Colon_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unsupported_locale_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unable_to_open_file_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Corrupted_locale_file_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_0_not_found: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + NEWLINE: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_0_can_only_be_specified_in_tsconfig_json_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enables_experimental_support_for_ES7_decorators: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enables_experimental_support_for_emitting_type_metadata_for_decorators: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enables_experimental_support_for_ES7_async_functions: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Successfully_created_a_tsconfig_json_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Suppress_excess_property_checks_for_object_literals: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Stylize_errors_and_messages_using_color_and_context_experimental: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_report_errors_on_unused_labels: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Report_error_when_not_all_code_paths_in_function_return_a_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Report_errors_for_fallthrough_cases_in_switch_statement: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_report_errors_on_unreachable_code: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Disallow_inconsistently_cased_references_to_the_same_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_library_files_to_be_included_in_the_compilation_Colon: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_JSX_code_generation_Colon_preserve_or_react: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_amd_and_system_modules_are_supported_alongside_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Base_directory_to_resolve_non_absolute_module_names: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enable_tracing_of_the_name_resolution_process: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_module_0_from_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Explicitly_specified_module_resolution_kind_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_resolution_kind_is_not_specified_using_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_name_0_was_successfully_resolved_to_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_name_0_was_not_resolved: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_name_0_matched_pattern_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Trying_substitution_0_candidate_module_location_Colon_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_module_name_0_relative_to_base_url_1_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Loading_module_as_file_Slash_folder_candidate_module_location_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_0_does_not_exist: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_0_exist_use_it_as_a_name_resolution_result: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Loading_module_0_from_node_modules_folder: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Found_package_json_at_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + package_json_does_not_have_a_types_or_main_field: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + package_json_has_0_field_1_that_references_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Allow_javascript_files_to_be_compiled: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Option_0_should_have_array_of_strings_as_a_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Checking_if_0_is_the_longest_matching_prefix_for_1_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expected_type_of_0_field_in_package_json_to_be_string_got_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Longest_matching_prefix_for_0_is_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Loading_0_from_the_root_dir_1_candidate_location_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Trying_other_entries_in_rootDirs: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_resolution_using_rootDirs_has_failed: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Do_not_emit_use_strict_directives_in_module_output: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Enable_strict_null_checks: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unknown_option_excludes_Did_you_mean_exclude: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Raise_error_on_this_expressions_with_an_implied_any_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_type_reference_directive_0_containing_file_1_root_directory_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_using_primary_search_paths: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_from_node_modules_folder: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_reference_directive_0_was_not_resolved: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_with_primary_search_path_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Root_directory_cannot_be_determined_skipping_primary_search_paths: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_declaration_files_to_be_included_in_compilation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Looking_up_in_node_modules_folder_initial_location_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_config_file_0_found_doesn_t_contain_any_source_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Resolving_real_path_for_0_result_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + File_name_0_has_a_1_extension_stripping_it: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_is_declared_but_never_used: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Report_errors_on_unused_locals: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Report_errors_on_unused_parameters: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + No_types_specified_in_package_json_so_returning_main_value_of_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_is_declared_but_never_used: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Import_emit_helpers_from_tslib: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { + code: number; + category: DiagnosticCategory; + 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; + key: string; + message: string; + }; + Parameter_0_implicitly_has_an_1_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Member_0_implicitly_has_an_1_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + 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; + message: string; + }; + Object_literal_s_property_0_implicitly_has_an_1_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Rest_parameter_0_implicitly_has_an_any_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _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: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Function_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: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unreachable_code_detected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unused_label: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Fallthrough_case_in_switch: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Not_all_code_paths_return_a_value: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Binding_element_0_implicitly_has_an_1_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + You_cannot_rename_this_element: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + import_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + export_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + type_parameter_declarations_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + implements_clauses_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + interface_declarations_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + module_declarations_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + type_aliases_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + _0_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + types_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + type_arguments_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + parameter_modifiers_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + enum_declarations_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + type_assertion_expressions_can_only_be_used_in_a_ts_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + class_expressions_are_not_currently_supported: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Expected_corresponding_JSX_closing_tag_for_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_attribute_expected: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + JSX_element_0_has_no_corresponding_closing_tag: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Unknown_typing_option_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Circularity_detected_while_resolving_configuration_Colon_0: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_path_in_an_extends_options_must_be_relative_or_rooted: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_files_list_in_config_file_0_is_empty: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Add_missing_super_call: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Make_super_call_the_first_statement_in_the_constructor: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Change_extends_to_implements: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Remove_unused_identifiers: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implement_interface_on_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implement_interface_on_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implement_inherited_abstract_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + 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: number; + category: DiagnosticCategory; + 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 { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } + function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean; interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -2070,13 +8537,24 @@ declare namespace ts { scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } + function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget): boolean; function tokenToString(t: SyntaxKind): string; + function stringToToken(s: string): SyntaxKind; + function computeLineStarts(text: string): number[]; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; + function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number; + function getLineStarts(sourceFile: SourceFile): number[]; + function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): { + line: number; + character: number; + }; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; + function isOctalDigit(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; + function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean, stopAtComments?: boolean): number; function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; @@ -2086,31 +8564,23 @@ declare namespace ts { function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierText(name: string, languageVersion: ScriptTarget): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } 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 isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; -} -declare namespace ts { - const version = "2.1.0"; - 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; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - interface FormatDiagnosticsHost { - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; + const compileOnSaveCommandLineOption: CommandLineOption; + const optionDeclarations: CommandLineOption[]; + let typingOptionDeclarations: CommandLineOption[]; + interface OptionNameMap { + optionNameMap: Map; + shortOptionNames: Map; } - 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; -} -declare namespace ts { + const defaultInitCompilerOptions: CompilerOptions; + function getOptionNameMap(): OptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic; + function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]): string | number; + function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] | undefined; + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic; @@ -2119,6 +8589,9 @@ declare namespace ts { config?: any; error?: Diagnostic; }; + function generateTSConfig(options: CompilerOptions, fileNames: string[]): { + compilerOptions: Map; + }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { @@ -2130,6 +8603,996 @@ declare namespace ts { errors: Diagnostic[]; }; } +declare namespace ts.JsTyping { + interface TypingResolutionHost { + directoryExists: (path: string) => boolean; + fileExists: (fileName: string) => boolean; + readFile: (path: string, encoding?: string) => string; + readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; + } + const nodeCoreModuleList: ReadonlyArray; + function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, unresolvedImports: ReadonlyArray): { + cachedTypingPaths: string[]; + newTypingNames: string[]; + filesToWatch: string[]; + }; +} +declare namespace ts.server { + const ActionSet: ActionSet; + const ActionInvalidate: ActionInvalidate; + const EventInstall: EventInstall; + namespace Arguments { + const GlobalCacheLocation = "--globalTypingsCacheLocation"; + const LogFile = "--logFile"; + const EnableTelemetry = "--enableTelemetry"; + } + function hasArgument(argumentName: string): boolean; + function findArgument(argumentName: string): string; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, + } + const emptyArray: ReadonlyArray; + interface Logger { + close(): void; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; + } + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMaps(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + const nullLanguageService: LanguageService; + interface ServerLanguageServiceHost { + setCompilationSettings(options: CompilerOptions): void; + notifyFileRemoved(info: ScriptInfo): void; + startRecordingFilesWithChangedResolutions(): void; + finishRecordingFilesWithChangedResolutions(): Path[]; + } + const nullLanguageServiceHost: ServerLanguageServiceHost; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typingOptions?: TypingOptions; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + function toSortedReadonlyArray(arr: string[]): SortedReadonlyArray; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); + } +} +declare namespace ts { + function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; + function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; + function getEffectiveTypeRoots(options: CompilerOptions, host: { + directoryExists?: (directoryName: string) => boolean; + getCurrentDirectory?: () => string; + }): string[] | undefined; + 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 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"; + interface ReferencePathMatchResult { + fileReference?: FileReference; + diagnosticMessage?: DiagnosticMessage; + isNoDefaultLib?: boolean; + isTypeReferenceDirective?: boolean; + } + function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; + interface StringSymbolWriter extends SymbolWriter { + string(): string; + } + interface EmitHost extends ScriptReferenceHost { + getSourceFiles(): SourceFile[]; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; + getCommonSourceDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + isEmitBlocked(emitFileName: string): boolean; + writeFile: WriteFileCallback; + } + function getSingleLineStringWriter(): StringSymbolWriter; + function releaseStringWriter(writer: StringSymbolWriter): void; + function getFullWidth(node: Node): number; + function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; + 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: 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; + function getSourceFileOfNode(node: Node): SourceFile; + function isStatementWithLocals(node: Node): boolean; + function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; + function nodePosToString(node: Node): string; + function getStartPosOfNode(node: Node): number; + function isDefined(value: any): boolean; + function getEndLinePosition(line: number, sourceFile: SourceFile): number; + function nodeIsMissing(node: Node): boolean; + function nodeIsPresent(node: Node): boolean; + function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDocComment?: boolean): number; + function isJSDocNode(node: Node): boolean; + function isJSDocTag(node: Node): boolean; + function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; + function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia?: boolean): string; + function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; + function getTextOfNode(node: Node, includeTrivia?: boolean): string; + function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget): string; + function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string): boolean; + function escapeIdentifier(identifier: string): string; + function unescapeIdentifier(identifier: string): string; + function makeIdentifierFromModuleName(moduleName: string): string; + function isBlockOrCatchScoped(declaration: Declaration): boolean; + function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; + function isAmbientModule(node: Node): boolean; + function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean; + function isBlockScopedContainerTopLevel(node: Node): boolean; + function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; + function isExternalModuleAugmentation(node: Node): boolean; + 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; + function isExternalOrCommonJsModule(file: SourceFile): boolean; + function isDeclarationFile(file: SourceFile): boolean; + function isConstEnumDeclaration(node: Node): boolean; + function isConst(node: Node): boolean; + function isLet(node: Node): boolean; + function isSuperCall(n: Node): n is SuperCall; + function isPrologueDirective(node: Node): boolean; + function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; + function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; + function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; + function getJsDocCommentsFromText(node: Node, text: string): CommentRange[]; + let fullTripleSlashReferencePathRegEx: RegExp; + let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; + let fullTripleSlashAMDReferencePathRegEx: RegExp; + function isPartOfTypeNode(node: Node): boolean; + function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; + function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; + function isVariableLike(node: Node): node is VariableLikeDeclaration; + function isAccessor(node: Node): node is AccessorDeclaration; + function isClassLike(node: Node): node is ClassLikeDeclaration; + function isFunctionLike(node: Node): node is FunctionLikeDeclaration; + function isFunctionLikeKind(kind: SyntaxKind): boolean; + function introducesArgumentsExoticObject(node: Node): boolean; + function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; + function isFunctionBlock(node: Node): boolean; + function isObjectLiteralMethod(node: Node): node is MethodDeclaration; + function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; + function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate; + function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate; + function getContainingFunction(node: Node): FunctionLikeDeclaration; + function getContainingClass(node: Node): ClassLikeDeclaration; + function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; + function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; + function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; + function isSuperProperty(node: Node): node is SuperProperty; + function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression; + function isCallLikeExpression(node: Node): node is CallLikeExpression; + function getInvokedExpression(node: CallLikeExpression): Expression; + function nodeCanBeDecorated(node: Node): boolean; + function nodeIsDecorated(node: Node): boolean; + function nodeOrChildIsDecorated(node: Node): boolean; + function childIsDecorated(node: Node): boolean; + function isJSXTagName(node: Node): boolean; + function isPartOfExpression(node: Node): boolean; + function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; + function isExternalModuleImportEqualsDeclaration(node: Node): boolean; + function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; + function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; + function isSourceFileJavaScript(file: SourceFile): boolean; + function isInJavaScriptFile(node: Node): boolean; + function isRequireCall(expression: Node, checkArgumentIsStringLiteral: boolean): expression is CallExpression; + function isSingleOrDoubleQuote(charCode: number): boolean; + function isDeclarationOfFunctionExpression(s: Symbol): boolean; + function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind; + function getExternalModuleName(node: Node): Expression; + function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport; + function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; + function hasQuestionToken(node: Node): boolean; + function isJSDocConstructSignature(node: Node): boolean; + function getJSDocComments(node: Node, checkParentVariableStatement: boolean): string[]; + function getJSDocTypeTag(node: Node): JSDocTypeTag; + function getJSDocReturnTag(node: Node): JSDocReturnTag; + function getJSDocTemplateTag(node: Node): JSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag; + function hasRestParameter(s: SignatureDeclaration): boolean; + 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; + function isDeclarationName(name: Node): boolean; + function isLiteralComputedPropertyDeclarationName(node: Node): boolean; + function isIdentifierName(node: Identifier): boolean; + function isAliasSymbolDeclaration(node: Node): boolean; + function exportAssignmentIsAlias(node: ExportAssignment): boolean; + function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments; + function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray; + function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; + function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; + function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile; + function getAncestor(node: Node, kind: SyntaxKind): Node; + function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; + function isKeyword(token: SyntaxKind): boolean; + function isTrivia(token: SyntaxKind): boolean; + function isAsyncFunctionLike(node: Node): boolean; + function isStringOrNumericLiteral(kind: SyntaxKind): boolean; + function hasDynamicName(declaration: Declaration): boolean; + function isDynamicName(name: DeclarationName): boolean; + function isWellKnownSymbolSyntactically(node: Expression): boolean; + function getPropertyNameForPropertyNameNode(name: DeclarationName): string; + function getPropertyNameForKnownSymbolName(symbolName: string): string; + function isESSymbolIdentifier(node: Node): boolean; + function isPushOrUnshiftIdentifier(node: Identifier): boolean; + function isModifierKind(token: SyntaxKind): boolean; + function isParameterDeclaration(node: VariableLikeDeclaration): boolean; + function getRootDeclaration(node: Node): Node; + 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; + function getOriginalSourceFiles(sourceFiles: SourceFile[]): SourceFile[]; + function getOriginalNodeId(node: Node): number; + const enum Associativity { + Left = 0, + Right = 1, + } + 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.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.MappedType | 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; + function isIntrinsicJsxName(name: string): boolean; + function escapeNonAsciiCharacters(s: string): string; + interface EmitTextWriter { + write(s: string): void; + writeTextOfNode(text: string, node: Node): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + getText(): string; + rawWrite(s: string): void; + writeLiteral(s: string): void; + getTextPos(): number; + getLine(): number; + getColumn(): number; + getIndent(): number; + isAtStartOfLine(): boolean; + reset(): void; + } + function getIndentString(level: number): string; + function getIndentSize(): number; + function createTextWriter(newLine: String): EmitTextWriter; + function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string; + function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string; + function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string; + function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; + function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; + interface EmitFileNames { + jsFilePath: string; + sourceMapFilePath: string; + declarationFilePath: string; + } + function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[]; + function filterSourceFilesInDirectory(sourceFiles: SourceFile[], isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): SourceFile[]; + function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, emitOnlyDtsFiles?: boolean): void; + function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean): void; + function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; + function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]): void; + function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; + function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number): number; + function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration; + function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode; + function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined; + function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; + function isThisIdentifier(node: Node | undefined): boolean; + function identifierIsThisKeyword(id: Identifier): boolean; + interface AllAccessorDeclarations { + firstAccessor: AccessorDeclaration; + secondAccessor: AccessorDeclaration; + getAccessor: AccessorDeclaration; + setAccessor: AccessorDeclaration; + } + function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap: number[], writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, leadingComments: CommentRange[]): void; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, commentPos: number): void; + function emitComments(text: string, lineMap: number[], writer: EmitTextWriter, comments: CommentRange[], leadingSeparator: boolean, trailingSeparator: boolean, newLine: string, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void): void; + function emitDetachedComments(text: string, lineMap: number[], writer: EmitTextWriter, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void, node: TextRange, newLine: string, removeComments: boolean): { + nodePos: number; + detachedCommentEndPos: number; + }; + function writeCommentRange(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string): void; + function hasModifiers(node: Node): boolean; + function hasModifier(node: Node, flags: ModifierFlags): boolean; + function getModifierFlags(node: Node): ModifierFlags; + function modifierToFlag(token: SyntaxKind): ModifierFlags; + function isLogicalOperator(token: SyntaxKind): boolean; + function isAssignmentOperator(token: SyntaxKind): boolean; + function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined; + 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; + function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; + function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean; + function getLocalSymbolForExportDefault(symbol: Symbol): Symbol; + function tryExtractTypeScriptExtension(fileName: string): string | undefined; + const stringify: (value: any) => string; + function convertToBase64(input: string): string; + function getNewLineCharacter(options: CompilerOptions): string; + function isSimpleExpression(node: Expression): boolean; + function formatSyntaxKind(kind: SyntaxKind): string; + function movePos(pos: number, value: number): number; + function createRange(pos: number, end: number): TextRange; + function moveRangeEnd(range: TextRange, end: number): TextRange; + function moveRangePos(range: TextRange, pos: number): TextRange; + function moveRangePastDecorators(node: Node): TextRange; + function moveRangePastModifiers(node: Node): TextRange; + function isCollapsedRange(range: TextRange): boolean; + function collapseRangeToStart(range: TextRange): TextRange; + function collapseRangeToEnd(range: TextRange): TextRange; + function createTokenRange(pos: number, token: SyntaxKind): TextRange; + function rangeIsOnSingleLine(range: TextRange, sourceFile: SourceFile): boolean; + function rangeStartPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; + function rangeEndPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; + function rangeStartIsOnSameLineAsRangeEnd(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; + 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; + interface ExternalModuleInfo { + externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; + exportSpecifiers: Map; + 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; + function isNodeArray(array: T[]): array is NodeArray; + function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression; + function isLiteralKind(kind: SyntaxKind): boolean; + function isTextualLiteralKind(kind: SyntaxKind): boolean; + function isLiteralExpression(node: Node): node is LiteralExpression; + function isTemplateLiteralKind(kind: SyntaxKind): boolean; + 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): node is GeneratedIdentifier; + function isModifier(node: Node): node is Modifier; + function isQualifiedName(node: Node): node is QualifiedName; + function isComputedPropertyName(node: Node): node is ComputedPropertyName; + function isEntityName(node: Node): node is EntityName; + function isPropertyName(node: Node): node is PropertyName; + function isModuleName(node: Node): node is ModuleName; + function isBindingName(node: Node): node is BindingName; + function isTypeParameter(node: Node): node is TypeParameterDeclaration; + function isParameter(node: Node): node is ParameterDeclaration; + function isDecorator(node: Node): node is Decorator; + function isMethodDeclaration(node: Node): node is MethodDeclaration; + function isClassElement(node: Node): node is ClassElement; + function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; + function isTypeNode(node: Node): node is TypeNode; + 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 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; + function isExpression(node: Node): node is Expression; + function isAssertionExpression(node: Node): node is AssertionExpression; + function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; + function isNotEmittedStatement(node: Node): node is NotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression; + function isOmittedExpression(node: Node): node is OmittedExpression; + function isTemplateSpan(node: Node): node is TemplateSpan; + function isBlock(node: Node): node is Block; + function isConciseBody(node: Node): node is ConciseBody; + function isFunctionBody(node: Node): node is FunctionBody; + function isForInitializer(node: Node): node is ForInitializer; + function isVariableDeclaration(node: Node): node is VariableDeclaration; + function isVariableDeclarationList(node: Node): node is VariableDeclarationList; + function isCaseBlock(node: Node): node is CaseBlock; + function isModuleBody(node: Node): node is ModuleBody; + function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; + function isImportClause(node: Node): node is ImportClause; + function isNamedImportBindings(node: Node): node is NamedImportBindings; + function isImportSpecifier(node: Node): node is ImportSpecifier; + function isNamedExports(node: Node): node is NamedExports; + function isExportSpecifier(node: Node): node is ExportSpecifier; + function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration; + function isDeclaration(node: Node): node is Declaration; + function isDeclarationStatement(node: Node): node is DeclarationStatement; + function isStatementButNotDeclaration(node: Node): node is Statement; + function isStatement(node: Node): node is Statement; + function isModuleReference(node: Node): node is ModuleReference; + function isJsxOpeningElement(node: Node): node is JsxOpeningElement; + function isJsxClosingElement(node: Node): node is JsxClosingElement; + function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; + function isJsxChild(node: Node): node is JsxChild; + function isJsxAttributeLike(node: Node): node is JsxAttributeLike; + function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; + function isJsxAttribute(node: Node): node is JsxAttribute; + function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression; + function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause; + function isHeritageClause(node: Node): node is HeritageClause; + function isCatchClause(node: Node): node is CatchClause; + function isPropertyAssignment(node: Node): node is PropertyAssignment; + function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment; + function isEnumMember(node: Node): node is EnumMember; + function isSourceFile(node: Node): node is SourceFile; + function isWatchSet(options: CompilerOptions): boolean; +} +declare namespace ts { + function getDefaultLibFileName(options: CompilerOptions): string; + function textSpanEnd(span: TextSpan): number; + function textSpanIsEmpty(span: TextSpan): boolean; + function textSpanContainsPosition(span: TextSpan, position: number): boolean; + function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; + function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; + function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; + function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; + function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; + function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; + function createTextSpan(start: number, length: number): TextSpan; + function createTextSpanFromBounds(start: number, end: number): TextSpan; + function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; + function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; + function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; + let unchangedTextChangeRange: TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + function getTypeParameterOwner(d: Declaration): Declaration; + function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean; + function getCombinedModifierFlags(node: Node): ModifierFlags; + function getCombinedNodeFlags(node: Node): NodeFlags; +} +declare namespace ts { + function updateNode(updated: T, original: T): T; + function createNodeArray(elements?: T[], location?: TextRange, hasTrailingComma?: boolean): NodeArray; + function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; + function createSynthesizedNodeArray(elements?: T[]): NodeArray; + function getSynthesizedClone(node: T): T; + function getMutableClone(node: T): T; + function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral; + function createLiteral(value: string, location?: TextRange): StringLiteral; + function createLiteral(value: number, location?: TextRange): NumericLiteral; + function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; + function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; + function createIdentifier(text: string, location?: TextRange): Identifier; + function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier; + function createLoopVariable(location?: TextRange): Identifier; + function createUniqueName(text: string, location?: TextRange): Identifier; + function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier; + function createToken(token: TKind): Token; + function createSuper(): PrimaryExpression; + function createThis(location?: TextRange): PrimaryExpression; + function createNull(): PrimaryExpression; + function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; + function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; + 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; + function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; + function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createObjectBindingPattern(elements: BindingElement[], location?: TextRange): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; + function updateBindingElement(node: BindingElement, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier, location?: TextRange, flags?: NodeFlags): PropertyAccessExpression; + function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createElementAccess(expression: Expression, index: number | Expression, location?: TextRange): ElementAccessExpression; + function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; + function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + function createParen(expression: Expression, location?: TextRange): ParenthesizedExpression; + function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; + function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createDelete(expression: Expression, location?: TextRange): DeleteExpression; + function updateDelete(node: DeleteExpression, expression: Expression): Expression; + function createTypeOf(expression: Expression, location?: TextRange): TypeOfExpression; + function updateTypeOf(node: TypeOfExpression, expression: Expression): Expression; + function createVoid(expression: Expression, location?: TextRange): VoidExpression; + function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; + function createAwait(expression: Expression, location?: TextRange): AwaitExpression; + function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange): PrefixUnaryExpression; + function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange): PostfixUnaryExpression; + function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange): BinaryExpression; + function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; + 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): 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; + function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; + function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block; + function updateBlock(node: Block, statements: Statement[]): Block; + function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableDeclarationList(declarations: VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; + function createVariableDeclaration(name: string | BindingPattern | Identifier, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function createEmptyStatement(location: TextRange): EmptyStatement; + function createStatement(expression: Expression, location?: TextRange, flags?: NodeFlags): ExpressionStatement; + function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement, location?: TextRange): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function createDo(statement: Statement, expression: Expression, location?: TextRange): DoStatement; + function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; + function createWhile(expression: Expression, statement: Statement, location?: TextRange): WhileStatement; + function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; + function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement, location?: TextRange): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForInStatement; + function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; + function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForOfStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: Identifier, location?: TextRange): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function createBreak(label?: Identifier, location?: TextRange): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function createReturn(expression?: Expression, location?: TextRange): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function createWith(expression: Expression, statement: Statement, location?: TextRange): WithStatement; + function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; + function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): SwitchStatement; + function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; + function createLabel(label: string | Identifier, statement: Statement, location?: TextRange): LabeledStatement; + function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; + function createThrow(expression: Expression, location?: TextRange): ThrowStatement; + function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; + function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; + function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportClause(name: Identifier, namedBindings: NamedImportBindings, location?: TextRange): ImportClause; + function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; + function createNamespaceImport(name: Identifier, location?: TextRange): NamespaceImport; + function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; + function createNamedImports(elements: ImportSpecifier[], location?: TextRange): NamedImports; + function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; + function createImportSpecifier(propertyName: Identifier, name: Identifier, location?: TextRange): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression, location?: TextRange): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression, location?: TextRange): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createNamedExports(elements: ExportSpecifier[], location?: TextRange): NamedExports; + function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; + function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier, location?: TextRange): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement, location?: TextRange): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxOpeningElement; + function createJsxClosingElement(tagName: JsxTagNameExpression, location?: TextRange): JsxClosingElement; + function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; + function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression, location?: TextRange): JsxAttribute; + function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; + function createJsxSpreadAttribute(expression: Expression, location?: TextRange): JsxSpreadAttribute; + function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; + function createJsxExpression(expression: Expression, location?: TextRange): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; + function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; + function createCaseClause(expression: Expression, statements: Statement[], location?: TextRange): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; + function createDefaultClause(statements: Statement[], location?: TextRange): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; + function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block, location?: TextRange): CatchClause; + function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; + 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; + function createLessThan(left: Expression, right: Expression, location?: TextRange): Expression; + function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression; + function createStrictEquality(left: Expression, right: Expression): BinaryExpression; + function createStrictInequality(left: Expression, right: Expression): BinaryExpression; + function createAdd(left: Expression, right: Expression): BinaryExpression; + function createSubtract(left: Expression, right: Expression): BinaryExpression; + function createPostfixIncrement(operand: Expression, location?: TextRange): PostfixUnaryExpression; + function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; + function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createLogicalNot(operand: Expression): PrefixUnaryExpression; + function createVoidZero(): VoidExpression; + function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; + 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 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; + function createExtendsHelper(externalHelpersModuleName: Identifier | undefined, name: Identifier): CallExpression; + function createAssignHelper(externalHelpersModuleName: Identifier | undefined, attributesSegments: Expression[]): CallExpression; + function createParamHelper(externalHelpersModuleName: Identifier | undefined, expression: Expression, parameterOffset: number, location?: TextRange): CallExpression; + function createMetadataHelper(externalHelpersModuleName: Identifier | undefined, metadataKey: string, metadataValue: Expression): CallExpression; + function createDecorateHelper(externalHelpersModuleName: Identifier | undefined, decoratorExpressions: Expression[], target: Expression, memberName?: Expression, descriptor?: Expression, location?: TextRange): CallExpression; + function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block): CallExpression; + function createHasOwnProperty(target: LeftHandSideExpression, propertyName: Expression): CallExpression; + function createAdvancedAsyncSuperHelper(): VariableStatement; + function createSimpleAsyncSuperHelper(): VariableStatement; + interface CallBinding { + target: LeftHandSideExpression; + thisArg: Expression; + } + function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; + function inlineExpressions(expressions: Expression[]): Expression; + 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; + function parenthesizeForNew(expression: Expression): LeftHandSideExpression; + function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; + function parenthesizePostfixOperand(operand: Expression): LeftHandSideExpression; + function parenthesizePrefixOperand(operand: Expression): UnaryExpression; + function parenthesizeExpressionForList(expression: Expression): Expression; + function parenthesizeExpressionForExpressionStatement(expression: Expression): Expression; + function parenthesizeConciseBody(body: ConciseBody): ConciseBody; + const enum OuterExpressionKinds { + Parentheses = 1, + Assertions = 2, + PartiallyEmittedExpressions = 4, + All = 7, + } + function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; + function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; + function skipParentheses(node: Expression): Expression; + function skipParentheses(node: Node): Node; + function skipAssertions(node: Expression): Expression; + function skipAssertions(node: Node): Node; + function skipPartiallyEmittedExpressions(node: Expression): Expression; + function skipPartiallyEmittedExpressions(node: Node): Node; + function startOnNewLine(node: T): T; + function setOriginalNode(node: T, original: Node): T; + function disposeEmitNodes(sourceFile: SourceFile): void; + function getEmitFlags(node: Node): EmitFlags; + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + function setSourceMapRange(node: T, range: TextRange): T; + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + function setCommentRange(node: T, range: TextRange): T; + function getCommentRange(node: Node): TextRange; + function getSourceMapRange(node: Node): TextRange; + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; + function setTextRange(node: T, location: TextRange): T; + function setNodeFlags(node: T, flags: NodeFlags): T; + function setMultiLine(node: T, multiLine: boolean): T; + function setHasTrailingComma(nodes: NodeArray, hasTrailingComma: boolean): NodeArray; + 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): { + jsDoc: JSDoc; + diagnostics: Diagnostic[]; + }; + function parseJSDocTypeExpressionForTests(content: string, start?: number, length?: number): { + jsDocTypeExpression: JSDocTypeExpression; + diagnostics: Diagnostic[]; + }; +} +declare namespace ts { + const enum ModuleInstanceState { + NonInstantiated = 0, + Instantiated = 1, + ConstEnumOnly = 2, + } + function getModuleInstanceState(node: Node): ModuleInstanceState; + function bindSourceFile(file: SourceFile, options: CompilerOptions): void; + function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags; + function getTransformFlagsSubtreeExclusions(kind: SyntaxKind): TransformFlags; +} +declare namespace ts { + function getNodeId(node: Node): number; + function getSymbolId(symbol: Symbol): number; + function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker; +} +declare namespace ts { + type VisitResult = T | T[]; + function reduceEachChild(node: Node, f: (memo: T, node: Node) => T, initial: T): T; + function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: NodeArray) => T): T; + function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional: boolean, lift: (node: NodeArray) => T, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): T; + function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start: number, count: number, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): NodeArray; + function visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: LexicalEnvironment): T; + function mergeFunctionBodyLexicalEnvironment(body: FunctionBody, declarations: Statement[]): FunctionBody; + function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody; + function liftToBlock(nodes: Node[]): Statement; + function aggregateTransformFlags(node: T): T; + namespace Debug { + const failNotOptional: typeof noop; + const failBadSyntaxKind: (node: Node, message?: string) => void; + const assertNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; + } +} +declare namespace ts { + 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; +} +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; +} +declare namespace ts { + function transformES2016(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + function transformES2015(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + function transformGenerators(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + function transformES5(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + function transformModule(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + function transformSystemModule(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + function transformES2015Module(context: TransformationContext): (node: SourceFile) => SourceFile; +} +declare namespace ts { + interface TransformationResult { + transformed: SourceFile[]; + emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + } + interface TransformationContext extends LexicalEnvironment { + getCompilerOptions(): CompilerOptions; + getEmitResolver(): EmitResolver; + getEmitHost(): EmitHost; + hoistFunctionDeclaration(node: FunctionDeclaration): void; + hoistVariableDeclaration(node: Identifier): void; + enableSubstitution(kind: SyntaxKind): void; + isSubstitutionEnabled(node: Node): boolean; + onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; + enableEmitNotification(kind: SyntaxKind): void; + isEmitNotificationEnabled(node: Node): boolean; + onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; + } + type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; + function getTransformers(compilerOptions: CompilerOptions): Transformer[]; + function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult; +} +declare namespace ts { + function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[]; + function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean): boolean; +} +declare namespace ts { + interface SourceMapWriter { + initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; + reset(): void; + setSourceFile(sourceFile: SourceFile): void; + emitPos(pos: number): void; + emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitTokenWithSourceMap(node: Node, token: SyntaxKind, tokenStartPos: number, emitCallback: (token: SyntaxKind, tokenStartPos: number) => number): number; + getText(): string; + getSourceMappingURL(): string; + getSourceMapData(): SourceMapData; + } + function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter; +} +declare namespace ts { + interface CommentWriter { + reset(): void; + setSourceFile(sourceFile: SourceFile): void; + emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; + emitTrailingCommentsOfPosition(pos: number): void; + } + function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter; +} +declare namespace ts { + function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; +} +declare namespace ts { + const version = "2.2.0"; + 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; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + interface FormatDiagnosticsHost { + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + } + 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 { getSourceFile(): SourceFile; @@ -2174,6 +9637,10 @@ declare namespace ts { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { + version: string; + scriptSnapshot: IScriptSnapshot; + nameTable: Map; + getNamedDeclarations(): Map; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; getPositionOfLineAndCharacter(line: number, character: number): number; @@ -2263,6 +9730,8 @@ declare namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; + getNonBoundSourceFile(fileName: string): SourceFile; + getSourceFile(fileName: string): SourceFile; dispose(): void; } interface Classifications { @@ -2654,8 +10123,123 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24, } } +declare namespace ts { + const scanner: Scanner; + const emptyArray: any[]; + const enum SemanticMeaning { + None = 0, + Value = 1, + Type = 2, + Namespace = 4, + All = 7, + } + function getMeaningFromDeclaration(node: Node): SemanticMeaning; + function getMeaningFromLocation(node: Node): SemanticMeaning; + function isCallExpressionTarget(node: Node): boolean; + function isNewExpressionTarget(node: Node): boolean; + function climbPastPropertyAccess(node: Node): Node; + function getTargetLabel(referenceNode: Node, labelName: string): Identifier; + function isJumpStatementTarget(node: Node): boolean; + function isLabelName(node: Node): boolean; + function isRightSideOfQualifiedName(node: Node): boolean; + function isRightSideOfPropertyAccess(node: Node): boolean; + function isNameOfModuleDeclaration(node: Node): boolean; + function isNameOfFunctionDeclaration(node: Node): boolean; + function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean; + function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node): boolean; + function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean; + function getContainerNode(node: Node): Declaration; + function getNodeKind(node: Node): string; + function getStringLiteralTypeForNode(node: StringLiteral | LiteralTypeNode, typeChecker: TypeChecker): LiteralType; + function isThis(node: Node): boolean; + interface ListItemInfo { + listItemIndex: number; + list: Node; + } + function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; + function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function startEndContainsRange(start: number, end: number, range: TextRange): boolean; + function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; + function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; + function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; + function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; + function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; + function findListItemInfo(node: Node): ListItemInfo; + function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; + function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; + function findContainingList(node: Node): Node; + function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; + function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; + function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; + function findNextToken(previousToken: Node, parent: Node): Node; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; + function isInString(sourceFile: SourceFile, position: number): boolean; + function isInComment(sourceFile: SourceFile, position: number): boolean; + function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; + function isInTemplateString(sourceFile: SourceFile, position: number): boolean; + function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; + function hasDocComment(sourceFile: SourceFile, position: number): boolean; + function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; + function getNodeModifiers(node: Node): string; + function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; + function isToken(n: Node): boolean; + function isWord(kind: SyntaxKind): boolean; + function isComment(kind: SyntaxKind): boolean; + function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; + function isPunctuation(kind: SyntaxKind): boolean; + function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; + function isAccessibilityModifier(kind: SyntaxKind): boolean; + function compareDataObjects(dst: any, src: any): boolean; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; + function hasTrailingDirectorySeparator(path: string): boolean; + function isInReferenceComment(sourceFile: SourceFile, position: number): boolean; + function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean; +} +declare namespace ts { + function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; + function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; + function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart; + function spacePart(): SymbolDisplayPart; + function keywordPart(kind: SyntaxKind): SymbolDisplayPart; + function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; + function operatorPart(kind: SyntaxKind): SymbolDisplayPart; + function textOrKeywordPart(text: string): SymbolDisplayPart; + function textPart(text: string): SymbolDisplayPart; + function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; + function lineBreakPart(): SymbolDisplayPart; + function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; + function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; + function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; + function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; + function isImportOrExportSpecifierName(location: Node): boolean; + function stripQuotes(name: string): string; + function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; + function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; + function sanitizeConfigFile(configFileName: string, content: string): { + configJsonObject: any; + diagnostics: Diagnostic[]; + }; +} +declare namespace ts.BreakpointResolver { + function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan; +} declare namespace ts { function createClassifier(): Classifier; + function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): ClassifiedSpan[]; + function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): Classifications; + function getSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): ClassifiedSpan[]; + function getEncodedSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): Classifications; +} +declare namespace ts.Completions { + function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo; + function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails; + function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol; +} +declare namespace ts.DocumentHighlights { + function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[]; } declare namespace ts { interface DocumentRegistry { @@ -2673,9 +10257,88 @@ declare namespace ts { }; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; } +declare namespace ts.FindAllReferences { + function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[]; + function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[]; + function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[]; + function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void; + function getReferenceEntryFromNode(node: Node): ReferenceEntry; +} +declare namespace ts.GoToDefinition { + function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[]; + function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[]; +} +declare namespace ts.GoToImplementation { + function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[]; +} +declare namespace ts.JsDoc { + function getJsDocCommentsFromDeclarations(declarations: Declaration[]): SymbolDisplayPart[]; + function getAllJsDocCompletionEntries(): CompletionEntry[]; + function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion; +} +declare namespace ts.NavigateTo { + function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[]; +} +declare namespace ts.NavigationBar { + function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[]; + function getNavigationTree(sourceFile: SourceFile): NavigationTree; +} +declare namespace ts.OutliningElementsCollector { + function collectElements(sourceFile: SourceFile): OutliningSpan[]; +} +declare namespace ts { + enum PatternMatchKind { + exact = 0, + prefix = 1, + substring = 2, + camelCase = 3, + } + interface PatternMatch { + kind: PatternMatchKind; + camelCaseWeight?: number; + isCaseSensitive: boolean; + punctuationStripped: boolean; + } + interface PatternMatcher { + getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[]; + getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; + patternContainsDots: boolean; + } + function createPatternMatcher(pattern: string): PatternMatcher; + function breakIntoCharacterSpans(identifier: string): TextSpan[]; + function breakIntoWordSpans(identifier: string): TextSpan[]; +} declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } +declare namespace ts.Rename { + function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo; +} +declare namespace ts.SignatureHelp { + const enum ArgumentListKind { + TypeArguments = 0, + CallArguments = 1, + TaggedTemplateArguments = 2, + } + interface ArgumentListInfo { + kind: ArgumentListKind; + invocation: CallLikeExpression; + argumentsSpan: TextSpan; + argumentIndex?: number; + argumentCount: number; + } + function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems; + function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; +} +declare namespace ts.SymbolDisplay { + function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; + function getSymbolModifiers(symbol: Symbol): string; + function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, location: Node, semanticMeaning?: SemanticMeaning): { + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + symbolKind: string; + }; +} declare namespace ts { interface TranspileOptions { compilerOptions?: CompilerOptions; @@ -2692,11 +10355,438 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } +declare namespace ts.formatting { + interface FormattingScanner { + advance(): void; + isOnToken(): boolean; + readTokenInfo(n: Node): TokenInfo; + getCurrentLeadingTrivia(): TextRangeWithKind[]; + lastTrailingTriviaWasNewLine(): boolean; + skipToEndOf(node: Node): void; + close(): void; + } + function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; +} +declare namespace ts.formatting { + class FormattingContext { + sourceFile: SourceFile; + formattingRequestKind: FormattingRequestKind; + currentTokenSpan: TextRangeWithKind; + nextTokenSpan: TextRangeWithKind; + contextNode: Node; + currentTokenParent: Node; + nextTokenParent: Node; + private contextNodeAllOnSameLine; + private nextNodeAllOnSameLine; + private tokensAreOnSameLine; + private contextNodeBlockIsOnOneLine; + private nextNodeBlockIsOnOneLine; + constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); + updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; + ContextNodeAllOnSameLine(): boolean; + NextNodeAllOnSameLine(): boolean; + TokensAreOnSameLine(): boolean; + ContextNodeBlockIsOnOneLine(): boolean; + NextNodeBlockIsOnOneLine(): boolean; + private NodeIsOnOneLine(node); + private BlockIsOnOneLine(node); + } +} +declare namespace ts.formatting { + const enum FormattingRequestKind { + FormatDocument = 0, + FormatSelection = 1, + FormatOnEnter = 2, + FormatOnSemicolon = 3, + FormatOnClosingCurlyBrace = 4, + } +} +declare namespace ts.formatting { + class Rule { + Descriptor: RuleDescriptor; + Operation: RuleOperation; + Flag: RuleFlags; + constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); + toString(): string; + } +} +declare namespace ts.formatting { + const enum RuleAction { + Ignore = 1, + Space = 2, + NewLine = 4, + Delete = 8, + } +} +declare namespace ts.formatting { + class RuleDescriptor { + LeftTokenRange: Shared.TokenRange; + RightTokenRange: Shared.TokenRange; + constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); + toString(): string; + static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; + static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; + static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; + static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; + } +} +declare namespace ts.formatting { + const enum RuleFlags { + None = 0, + CanDeleteNewLines = 1, + } +} +declare namespace ts.formatting { + class RuleOperation { + Context: RuleOperationContext; + Action: RuleAction; + constructor(Context: RuleOperationContext, Action: RuleAction); + toString(): string; + static create1(action: RuleAction): RuleOperation; + static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; + } +} +declare namespace ts.formatting { + class RuleOperationContext { + private customContextChecks; + constructor(...funcs: { + (context: FormattingContext): boolean; + }[]); + static Any: RuleOperationContext; + IsAny(): boolean; + InContext(context: FormattingContext): boolean; + } +} +declare namespace ts.formatting { + class Rules { + getRuleName(rule: Rule): string; + [name: string]: any; + IgnoreBeforeComment: Rule; + IgnoreAfterLineComment: Rule; + NoSpaceBeforeSemicolon: Rule; + NoSpaceBeforeColon: Rule; + NoSpaceBeforeQuestionMark: Rule; + SpaceAfterColon: Rule; + SpaceAfterQuestionMarkInConditionalOperator: Rule; + NoSpaceAfterQuestionMark: Rule; + SpaceAfterSemicolon: Rule; + SpaceAfterCloseBrace: Rule; + SpaceBetweenCloseBraceAndElse: Rule; + SpaceBetweenCloseBraceAndWhile: Rule; + NoSpaceAfterCloseBrace: Rule; + NoSpaceBeforeDot: Rule; + NoSpaceAfterDot: Rule; + NoSpaceBeforeOpenBracket: Rule; + NoSpaceAfterCloseBracket: Rule; + SpaceAfterOpenBrace: Rule; + SpaceBeforeCloseBrace: Rule; + NoSpaceAfterOpenBrace: Rule; + NoSpaceBeforeCloseBrace: Rule; + NoSpaceBetweenEmptyBraceBrackets: Rule; + NewLineAfterOpenBraceInBlockContext: Rule; + NewLineBeforeCloseBraceInBlockContext: Rule; + NoSpaceAfterUnaryPrefixOperator: Rule; + NoSpaceAfterUnaryPreincrementOperator: Rule; + NoSpaceAfterUnaryPredecrementOperator: Rule; + NoSpaceBeforeUnaryPostincrementOperator: Rule; + NoSpaceBeforeUnaryPostdecrementOperator: Rule; + SpaceAfterPostincrementWhenFollowedByAdd: Rule; + SpaceAfterAddWhenFollowedByUnaryPlus: Rule; + SpaceAfterAddWhenFollowedByPreincrement: Rule; + SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; + SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; + SpaceAfterSubtractWhenFollowedByPredecrement: Rule; + NoSpaceBeforeComma: Rule; + SpaceAfterCertainKeywords: Rule; + SpaceAfterLetConstInVariableDeclaration: Rule; + NoSpaceBeforeOpenParenInFuncCall: Rule; + SpaceAfterFunctionInFuncDecl: Rule; + NoSpaceBeforeOpenParenInFuncDecl: Rule; + SpaceAfterVoidOperator: Rule; + NoSpaceBetweenReturnAndSemicolon: Rule; + SpaceBetweenStatements: Rule; + SpaceAfterTryFinally: Rule; + SpaceAfterGetSetInMember: Rule; + SpaceBeforeBinaryKeywordOperator: Rule; + SpaceAfterBinaryKeywordOperator: Rule; + NoSpaceAfterConstructor: Rule; + NoSpaceAfterModuleImport: Rule; + SpaceAfterCertainTypeScriptKeywords: Rule; + SpaceBeforeCertainTypeScriptKeywords: Rule; + SpaceAfterModuleName: Rule; + SpaceBeforeArrow: Rule; + SpaceAfterArrow: Rule; + NoSpaceAfterEllipsis: Rule; + NoSpaceAfterOptionalParameters: Rule; + NoSpaceBeforeOpenAngularBracket: Rule; + NoSpaceBetweenCloseParenAndAngularBracket: Rule; + NoSpaceAfterOpenAngularBracket: Rule; + NoSpaceBeforeCloseAngularBracket: Rule; + NoSpaceAfterCloseAngularBracket: Rule; + NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; + HighPriorityCommonRules: Rule[]; + LowPriorityCommonRules: Rule[]; + SpaceAfterComma: Rule; + NoSpaceAfterComma: Rule; + SpaceBeforeBinaryOperator: Rule; + SpaceAfterBinaryOperator: Rule; + NoSpaceBeforeBinaryOperator: Rule; + NoSpaceAfterBinaryOperator: Rule; + SpaceAfterKeywordInControl: Rule; + NoSpaceAfterKeywordInControl: Rule; + FunctionOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInFunction: Rule; + NewLineBeforeOpenBraceInFunction: Rule; + TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; + NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; + ControlOpenBraceLeftTokenRange: Shared.TokenRange; + SpaceBeforeOpenBraceInControl: Rule; + NewLineBeforeOpenBraceInControl: Rule; + SpaceAfterSemicolonInFor: Rule; + NoSpaceAfterSemicolonInFor: Rule; + SpaceAfterOpenParen: Rule; + SpaceBeforeCloseParen: Rule; + NoSpaceBetweenParens: Rule; + NoSpaceAfterOpenParen: Rule; + NoSpaceBeforeCloseParen: Rule; + SpaceAfterOpenBracket: Rule; + SpaceBeforeCloseBracket: Rule; + NoSpaceBetweenBrackets: Rule; + NoSpaceAfterOpenBracket: Rule; + NoSpaceBeforeCloseBracket: Rule; + SpaceAfterAnonymousFunctionKeyword: Rule; + NoSpaceAfterAnonymousFunctionKeyword: Rule; + SpaceBeforeAt: Rule; + NoSpaceAfterAt: Rule; + SpaceAfterDecorator: Rule; + NoSpaceBetweenFunctionKeywordAndStar: Rule; + SpaceAfterStarInGeneratorDeclaration: Rule; + NoSpaceBetweenYieldKeywordAndStar: Rule; + SpaceBetweenYieldOrYieldStarAndOperand: Rule; + SpaceBetweenAsyncAndOpenParen: Rule; + SpaceBetweenAsyncAndFunctionKeyword: Rule; + NoSpaceBetweenTagAndTemplateString: Rule; + NoSpaceAfterTemplateHeadAndMiddle: Rule; + SpaceAfterTemplateHeadAndMiddle: Rule; + NoSpaceBeforeTemplateMiddleAndTail: Rule; + SpaceBeforeTemplateMiddleAndTail: Rule; + NoSpaceAfterOpenBraceInJsxExpression: Rule; + SpaceAfterOpenBraceInJsxExpression: Rule; + NoSpaceBeforeCloseBraceInJsxExpression: Rule; + SpaceBeforeCloseBraceInJsxExpression: Rule; + SpaceBeforeJsxAttribute: Rule; + SpaceBeforeSlashInJsxOpeningElement: Rule; + NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; + NoSpaceBeforeEqualInJsxAttribute: Rule; + NoSpaceAfterEqualInJsxAttribute: Rule; + NoSpaceAfterTypeAssertion: Rule; + SpaceAfterTypeAssertion: Rule; + constructor(); + static IsForContext(context: FormattingContext): boolean; + static IsNotForContext(context: FormattingContext): boolean; + static IsBinaryOpContext(context: FormattingContext): boolean; + static IsNotBinaryOpContext(context: FormattingContext): boolean; + static IsConditionalOperatorContext(context: FormattingContext): boolean; + static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; + static IsMultilineBlockContext(context: FormattingContext): boolean; + static IsSingleLineBlockContext(context: FormattingContext): boolean; + static IsBlockContext(context: FormattingContext): boolean; + static IsBeforeBlockContext(context: FormattingContext): boolean; + static NodeIsBlockContext(node: Node): boolean; + static IsFunctionDeclContext(context: FormattingContext): boolean; + static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; + static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; + static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; + static IsAfterCodeBlockContext(context: FormattingContext): boolean; + static IsControlDeclContext(context: FormattingContext): boolean; + static IsObjectContext(context: FormattingContext): boolean; + static IsFunctionCallContext(context: FormattingContext): boolean; + static IsNewContext(context: FormattingContext): boolean; + static IsFunctionCallOrNewContext(context: FormattingContext): boolean; + static IsPreviousTokenNotComma(context: FormattingContext): boolean; + static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; + static IsArrowFunctionContext(context: FormattingContext): boolean; + static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; + static IsNonJsxElementContext(context: FormattingContext): boolean; + static IsJsxExpressionContext(context: FormattingContext): boolean; + static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; + static IsJsxAttributeContext(context: FormattingContext): boolean; + static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; + static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; + static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; + static NodeIsInDecoratorContext(node: Node): boolean; + static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; + static IsNotFormatOnEnter(context: FormattingContext): boolean; + static IsModuleDeclContext(context: FormattingContext): boolean; + static IsObjectTypeContext(context: FormattingContext): boolean; + static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; + static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; + static IsTypeAssertionContext(context: FormattingContext): boolean; + static IsVoidOpContext(context: FormattingContext): boolean; + static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; + } +} +declare namespace ts.formatting { + class RulesMap { + map: RulesBucket[]; + mapRowLength: number; + constructor(); + static create(rules: Rule[]): RulesMap; + Initialize(rules: Rule[]): RulesBucket[]; + FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; + private GetRuleBucketIndex(row, column); + private FillRule(rule, rulesBucketConstructionStateList); + GetRule(context: FormattingContext): Rule; + } + enum RulesPosition { + IgnoreRulesSpecific = 0, + IgnoreRulesAny, + ContextRulesSpecific, + ContextRulesAny, + NoContextRulesSpecific, + NoContextRulesAny, + } + class RulesBucketConstructionState { + private rulesInsertionIndexBitmap; + constructor(); + GetInsertionIndex(maskPosition: RulesPosition): number; + IncreaseInsertionIndex(maskPosition: RulesPosition): void; + } + class RulesBucket { + private rules; + constructor(); + Rules(): Rule[]; + AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; + } +} +declare namespace ts.formatting { + namespace Shared { + interface ITokenAccess { + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenRangeAccess implements ITokenAccess { + private tokens; + constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenValuesAccess implements ITokenAccess { + private tokens; + constructor(tks: SyntaxKind[]); + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + } + class TokenSingleValueAccess implements ITokenAccess { + token: SyntaxKind; + constructor(token: SyntaxKind); + GetTokens(): SyntaxKind[]; + Contains(tokenValue: SyntaxKind): boolean; + } + class TokenAllAccess implements ITokenAccess { + GetTokens(): SyntaxKind[]; + Contains(): boolean; + toString(): string; + } + class TokenRange { + tokenAccess: ITokenAccess; + constructor(tokenAccess: ITokenAccess); + static FromToken(token: SyntaxKind): TokenRange; + static FromTokens(tokens: SyntaxKind[]): TokenRange; + static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; + static AllTokens(): TokenRange; + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + toString(): string; + static Any: TokenRange; + static AnyIncludingMultilineComments: TokenRange; + static Keywords: TokenRange; + static BinaryOperators: TokenRange; + static BinaryKeywordOperators: TokenRange; + static UnaryPrefixOperators: TokenRange; + static UnaryPrefixExpressions: TokenRange; + static UnaryPreincrementExpressions: TokenRange; + static UnaryPostincrementExpressions: TokenRange; + static UnaryPredecrementExpressions: TokenRange; + static UnaryPostdecrementExpressions: TokenRange; + static Comments: TokenRange; + static TypeNames: TokenRange; + } + } +} +declare namespace ts.formatting { + class RulesProvider { + private globalRules; + private options; + private activeRules; + private rulesMap; + constructor(); + getRuleName(rule: Rule): string; + getRuleByName(name: string): Rule; + getRulesMap(): RulesMap; + ensureUpToDate(options: ts.FormatCodeSettings): void; + private createActiveRules(options); + } +} +declare namespace ts.formatting { + interface TextRangeWithKind extends TextRange { + kind: SyntaxKind; + } + interface TokenInfo { + leadingTrivia: TextRangeWithKind[]; + token: TextRangeWithKind; + trailingTrivia: TextRangeWithKind[]; + } + function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function getIndentationString(indentation: number, options: EditorSettings): string; +} +declare namespace ts.formatting { + namespace SmartIndenter { + function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number; + function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; + function getBaseIndentation(options: EditorSettings): number; + function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; + function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): { + column: number; + character: number; + }; + function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number; + function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; + function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; + } +} +declare namespace ts { + interface CodeFix { + errorCodes: number[]; + getCodeActions(context: CodeFixContext): CodeAction[] | undefined; + } + interface CodeFixContext { + errorCode: number; + sourceFile: SourceFile; + span: TextSpan; + program: Program; + newLineCharacter: string; + } + namespace codefix { + function registerCodeFix(action: CodeFix): void; + function getSupportedErrorCodes(): string[]; + function getFixes(context: CodeFixContext): CodeAction[]; + } +} +declare namespace ts.codefix { +} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } + function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; @@ -2705,840 +10795,9 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; + function getNameTable(sourceFile: SourceFile): Map; function getDefaultLibFilePath(options: CompilerOptions): string; } -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, - } - const emptyArray: ReadonlyArray; - interface Logger { - close(): void; - hasLevel(level: LogLevel): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: Msg.Types): void; - getLogFileName(): string; - } - namespace Msg { - type Err = "Err"; - const Err: Err; - type Info = "Info"; - const Info: Info; - type Perf = "Perf"; - const Perf: Perf; - type Types = Err | Info | Perf; - } - function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; - } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; - function mergeMaps(target: MapLike, source: MapLike): void; - function removeItemFromSet(items: T[], itemToRemove: T): void; - type NormalizedPath = string & { - __normalizedPathTag: any; - }; - function toNormalizedPath(fileName: string): NormalizedPath; - function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; - function asNormalizedPath(fileName: string): NormalizedPath; - interface NormalizedPathMap { - get(path: NormalizedPath): T; - set(path: NormalizedPath, value: T): void; - contains(path: NormalizedPath): boolean; - remove(path: NormalizedPath): void; - } - function createNormalizedPathMap(): NormalizedPathMap; - const nullLanguageService: LanguageService; - interface ServerLanguageServiceHost { - setCompilationSettings(options: CompilerOptions): void; - notifyFileRemoved(info: ScriptInfo): void; - } - const nullLanguageServiceHost: ServerLanguageServiceHost; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typingOptions?: TypingOptions; - compileOnSave?: boolean; - } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); - } - class GcTimer { - private readonly host; - private readonly delay; - private readonly logger; - private timerId; - constructor(host: ServerHost, delay: number, logger: Logger); - scheduleCollect(): void; - private static run(self); - } -} -declare namespace ts.server.protocol { - namespace CommandTypes { - type Brace = "brace"; - type BraceCompletion = "braceCompletion"; - type Change = "change"; - type Close = "close"; - type Completions = "completions"; - type CompletionDetails = "completionEntryDetails"; - type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - type Configure = "configure"; - type Definition = "definition"; - type Implementation = "implementation"; - type Exit = "exit"; - type Format = "format"; - type Formatonkey = "formatonkey"; - type Geterr = "geterr"; - type GeterrForProject = "geterrForProject"; - type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - type NavBar = "navbar"; - type Navto = "navto"; - type NavTree = "navtree"; - type NavTreeFull = "navtree-full"; - type Occurrences = "occurrences"; - type DocumentHighlights = "documentHighlights"; - type Open = "open"; - type Quickinfo = "quickinfo"; - type References = "references"; - type Reload = "reload"; - type Rename = "rename"; - type Saveto = "saveto"; - type SignatureHelp = "signatureHelp"; - type TypeDefinition = "typeDefinition"; - type ProjectInfo = "projectInfo"; - type ReloadProjects = "reloadProjects"; - type Unknown = "unknown"; - type OpenExternalProject = "openExternalProject"; - type OpenExternalProjects = "openExternalProjects"; - type CloseExternalProject = "closeExternalProject"; - type TodoComments = "todoComments"; - type Indentation = "indentation"; - type DocCommentTemplate = "docCommentTemplate"; - type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - type GetCodeFixes = "getCodeFixes"; - type GetSupportedCodeFixes = "getSupportedCodeFixes"; - } - interface Message { - seq: number; - type: "request" | "response" | "event"; - } - interface Request extends Message { - command: string; - arguments?: any; - } - interface ReloadProjectsRequest extends Message { - command: CommandTypes.ReloadProjects; - } - interface Event extends Message { - event: string; - body?: any; - } - interface Response extends Message { - request_seq: number; - success: boolean; - command: string; - message?: string; - body?: any; - } - interface FileRequestArgs { - file: string; - projectFileName?: string; - } - interface DocCommentTemplateRequest extends FileLocationRequest { - command: CommandTypes.DocCommentTemplate; - } - interface DocCommandTemplateResponse extends Response { - body?: TextInsertion; - } - interface TodoCommentRequest extends FileRequest { - command: CommandTypes.TodoComments; - arguments: TodoCommentRequestArgs; - } - interface TodoCommentRequestArgs extends FileRequestArgs { - descriptors: TodoCommentDescriptor[]; - } - interface TodoCommentsResponse extends Response { - body?: TodoComment[]; - } - interface IndentationRequest extends FileLocationRequest { - command: CommandTypes.Indentation; - arguments: IndentationRequestArgs; - } - interface IndentationResponse extends Response { - body?: IndentationResult; - } - interface IndentationResult { - position: number; - indentation: number; - } - interface IndentationRequestArgs extends FileLocationRequestArgs { - options?: EditorSettings; - } - interface ProjectInfoRequestArgs extends FileRequestArgs { - needFileNameList: boolean; - } - interface ProjectInfoRequest extends Request { - command: CommandTypes.ProjectInfo; - arguments: ProjectInfoRequestArgs; - } - interface CompilerOptionsDiagnosticsRequest extends Request { - arguments: CompilerOptionsDiagnosticsRequestArgs; - } - interface CompilerOptionsDiagnosticsRequestArgs { - projectFileName: string; - } - interface ProjectInfo { - configFileName: string; - fileNames?: string[]; - languageServiceDisabled?: boolean; - } - interface DiagnosticWithLinePosition { - message: string; - start: number; - length: number; - startLocation: Location; - endLocation: Location; - category: string; - code: number; - } - interface ProjectInfoResponse extends Response { - body?: ProjectInfo; - } - interface FileRequest extends Request { - arguments: FileRequestArgs; - } - interface FileLocationRequestArgs extends FileRequestArgs { - line: number; - offset: number; - } - interface CodeFixRequest extends Request { - command: CommandTypes.GetCodeFixes; - arguments: CodeFixRequestArgs; - } - interface CodeFixRequestArgs extends FileRequestArgs { - startLine: number; - startOffset: number; - endLine: number; - endOffset: number; - errorCodes?: number[]; - } - interface GetCodeFixesResponse extends Response { - body?: CodeAction[]; - } - interface FileLocationRequest extends FileRequest { - arguments: FileLocationRequestArgs; - } - interface GetSupportedCodeFixesRequest extends Request { - command: CommandTypes.GetSupportedCodeFixes; - } - interface GetSupportedCodeFixesResponse extends Response { - body?: string[]; - } - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - start: number; - length: number; - } - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { - filesToSearch: string[]; - } - interface DefinitionRequest extends FileLocationRequest { - command: CommandTypes.Definition; - } - interface TypeDefinitionRequest extends FileLocationRequest { - command: CommandTypes.TypeDefinition; - } - interface ImplementationRequest extends FileLocationRequest { - command: CommandTypes.Implementation; - } - interface Location { - line: number; - offset: number; - } - interface TextSpan { - start: Location; - end: Location; - } - interface FileSpan extends TextSpan { - file: string; - } - interface DefinitionResponse extends Response { - body?: FileSpan[]; - } - interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; - } - interface ImplementationResponse extends Response { - body?: FileSpan[]; - } - interface BraceCompletionRequest extends FileLocationRequest { - command: CommandTypes.BraceCompletion; - arguments: BraceCompletionRequestArgs; - } - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { - openingBrace: string; - } - interface OccurrencesRequest extends FileLocationRequest { - command: CommandTypes.Occurrences; - } - interface OccurrencesResponseItem extends FileSpan { - isWriteAccess: boolean; - } - interface OccurrencesResponse extends Response { - body?: OccurrencesResponseItem[]; - } - interface DocumentHighlightsRequest extends FileLocationRequest { - command: CommandTypes.DocumentHighlights; - arguments: DocumentHighlightsRequestArgs; - } - interface HighlightSpan extends TextSpan { - kind: string; - } - interface DocumentHighlightsItem { - file: string; - highlightSpans: HighlightSpan[]; - } - interface DocumentHighlightsResponse extends Response { - body?: DocumentHighlightsItem[]; - } - interface ReferencesRequest extends FileLocationRequest { - command: CommandTypes.References; - } - interface ReferencesResponseItem extends FileSpan { - lineText: string; - isWriteAccess: boolean; - isDefinition: boolean; - } - interface ReferencesResponseBody { - refs: ReferencesResponseItem[]; - symbolName: string; - symbolStartOffset: number; - symbolDisplayString: string; - } - interface ReferencesResponse extends Response { - body?: ReferencesResponseBody; - } - interface RenameRequestArgs extends FileLocationRequestArgs { - findInComments?: boolean; - findInStrings?: boolean; - } - interface RenameRequest extends FileLocationRequest { - command: CommandTypes.Rename; - arguments: RenameRequestArgs; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage?: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - } - interface SpanGroup { - file: string; - locs: TextSpan[]; - } - interface RenameResponseBody { - info: RenameInfo; - locs: SpanGroup[]; - } - interface RenameResponse extends Response { - body?: RenameResponseBody; - } - interface ExternalFile { - fileName: string; - scriptKind?: ScriptKindName | ts.ScriptKind; - hasMixedContent?: boolean; - content?: string; - } - interface ExternalProject { - projectFileName: string; - rootFiles: ExternalFile[]; - options: ExternalProjectCompilerOptions; - typingOptions?: TypingOptions; - } - interface CompileOnSaveMixin { - compileOnSave?: boolean; - } - type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; - interface ProjectChanges { - added: string[]; - removed: string[]; - } - interface ConfigureRequestArguments { - hostInfo?: string; - file?: string; - formatOptions?: FormatCodeSettings; - } - interface ConfigureRequest extends Request { - command: CommandTypes.Configure; - arguments: ConfigureRequestArguments; - } - interface ConfigureResponse extends Response { - } - interface OpenRequestArgs extends FileRequestArgs { - fileContent?: string; - scriptKindName?: ScriptKindName; - } - type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; - interface OpenRequest extends Request { - command: CommandTypes.Open; - arguments: OpenRequestArgs; - } - interface OpenExternalProjectRequest extends Request { - command: CommandTypes.OpenExternalProject; - arguments: OpenExternalProjectArgs; - } - type OpenExternalProjectArgs = ExternalProject; - interface OpenExternalProjectsRequest extends Request { - command: CommandTypes.OpenExternalProjects; - arguments: OpenExternalProjectsArgs; - } - interface OpenExternalProjectsArgs { - projects: ExternalProject[]; - } - interface OpenExternalProjectResponse extends Response { - } - interface OpenExternalProjectsResponse extends Response { - } - interface CloseExternalProjectRequest extends Request { - command: CommandTypes.CloseExternalProject; - arguments: CloseExternalProjectRequestArgs; - } - interface CloseExternalProjectRequestArgs { - projectFileName: string; - } - interface CloseExternalProjectResponse extends Response { - } - interface SetCompilerOptionsForInferredProjectsRequest extends Request { - command: CommandTypes.CompilerOptionsForInferredProjects; - arguments: SetCompilerOptionsForInferredProjectsArgs; - } - interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; - } - interface SetCompilerOptionsForInferredProjectsResponse extends Response { - } - interface ExitRequest extends Request { - command: CommandTypes.Exit; - } - interface CloseRequest extends FileRequest { - command: CommandTypes.Close; - } - interface CompileOnSaveAffectedFileListRequest extends FileRequest { - command: CommandTypes.CompileOnSaveAffectedFileList; - } - interface CompileOnSaveAffectedFileListSingleProject { - projectFileName: string; - fileNames: string[]; - } - interface CompileOnSaveAffectedFileListResponse extends Response { - body: CompileOnSaveAffectedFileListSingleProject[]; - } - interface CompileOnSaveEmitFileRequest extends FileRequest { - command: CommandTypes.CompileOnSaveEmitFile; - arguments: CompileOnSaveEmitFileRequestArgs; - } - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { - forced?: boolean; - } - interface QuickInfoRequest extends FileLocationRequest { - command: CommandTypes.Quickinfo; - } - interface QuickInfoResponseBody { - kind: string; - kindModifiers: string; - start: Location; - end: Location; - displayString: string; - documentation: string; - } - interface QuickInfoResponse extends Response { - body?: QuickInfoResponseBody; - } - interface FormatRequestArgs extends FileLocationRequestArgs { - endLine: number; - endOffset: number; - options?: FormatCodeSettings; - } - interface FormatRequest extends FileLocationRequest { - command: CommandTypes.Format; - arguments: FormatRequestArgs; - } - interface CodeEdit { - start: Location; - end: Location; - newText: string; - } - interface FileCodeEdits { - fileName: string; - textChanges: CodeEdit[]; - } - interface CodeFixResponse extends Response { - body?: CodeAction[]; - } - interface CodeAction { - description: string; - changes: FileCodeEdits[]; - } - interface FormatResponse extends Response { - body?: CodeEdit[]; - } - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { - key: string; - options?: FormatCodeSettings; - } - interface FormatOnKeyRequest extends FileLocationRequest { - command: CommandTypes.Formatonkey; - arguments: FormatOnKeyRequestArgs; - } - interface CompletionsRequestArgs extends FileLocationRequestArgs { - prefix?: string; - } - interface CompletionsRequest extends FileLocationRequest { - command: CommandTypes.Completions; - arguments: CompletionsRequestArgs; - } - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { - entryNames: string[]; - } - interface CompletionDetailsRequest extends FileLocationRequest { - command: CommandTypes.CompletionDetails; - arguments: CompletionDetailsRequestArgs; - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface CompletionsResponse extends Response { - body?: CompletionEntry[]; - } - interface CompletionDetailsResponse extends Response { - body?: CompletionEntryDetails[]; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { - } - interface SignatureHelpRequest extends FileLocationRequest { - command: CommandTypes.SignatureHelp; - arguments: SignatureHelpRequestArgs; - } - interface SignatureHelpResponse extends Response { - body?: SignatureHelpItems; - } - interface SemanticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SemanticDiagnosticsSync; - arguments: SemanticDiagnosticsSyncRequestArgs; - } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SemanticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface SyntacticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SyntacticDiagnosticsSync; - arguments: SyntacticDiagnosticsSyncRequestArgs; - } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SyntacticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface GeterrForProjectRequestArgs { - file: string; - delay: number; - } - interface GeterrForProjectRequest extends Request { - command: CommandTypes.GeterrForProject; - arguments: GeterrForProjectRequestArgs; - } - interface GeterrRequestArgs { - files: string[]; - delay: number; - } - interface GeterrRequest extends Request { - command: CommandTypes.Geterr; - arguments: GeterrRequestArgs; - } - interface Diagnostic { - start: Location; - end: Location; - text: string; - code?: number; - } - interface DiagnosticEventBody { - file: string; - diagnostics: Diagnostic[]; - } - interface DiagnosticEvent extends Event { - body?: DiagnosticEventBody; - } - interface ConfigFileDiagnosticEventBody { - triggerFile: string; - configFile: string; - diagnostics: Diagnostic[]; - } - interface ConfigFileDiagnosticEvent extends Event { - body?: ConfigFileDiagnosticEventBody; - event: "configFileDiag"; - } - interface ReloadRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface ReloadRequest extends FileRequest { - command: CommandTypes.Reload; - arguments: ReloadRequestArgs; - } - interface ReloadResponse extends Response { - } - interface SavetoRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface SavetoRequest extends FileRequest { - command: CommandTypes.Saveto; - arguments: SavetoRequestArgs; - } - interface NavtoRequestArgs extends FileRequestArgs { - searchValue: string; - maxResultCount?: number; - currentFileOnly?: boolean; - projectFileName?: string; - } - interface NavtoRequest extends FileRequest { - command: CommandTypes.Navto; - arguments: NavtoRequestArgs; - } - interface NavtoItem { - name: string; - kind: string; - matchKind?: string; - isCaseSensitive?: boolean; - kindModifiers?: string; - file: string; - start: Location; - end: Location; - containerName?: string; - containerKind?: string; - } - interface NavtoResponse extends Response { - body?: NavtoItem[]; - } - interface ChangeRequestArgs extends FormatRequestArgs { - insertString?: string; - } - interface ChangeRequest extends FileLocationRequest { - command: CommandTypes.Change; - arguments: ChangeRequestArgs; - } - interface BraceResponse extends Response { - body?: TextSpan[]; - } - interface BraceRequest extends FileLocationRequest { - command: CommandTypes.Brace; - } - interface NavBarRequest extends FileRequest { - command: CommandTypes.NavBar; - } - interface NavTreeRequest extends FileRequest { - command: CommandTypes.NavTree; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers?: string; - spans: TextSpan[]; - childItems?: NavigationBarItem[]; - indent: number; - } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; - } - interface NavBarResponse extends Response { - body?: NavigationBarItem[]; - } - interface NavTreeResponse extends Response { - body?: NavigationTree; - } - namespace IndentStyle { - type None = "None"; - type Block = "Block"; - type Smart = "Smart"; - } - type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle | ts.IndentStyle; - } - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - } - interface CompilerOptions { - allowJs?: boolean; - allowSyntheticDefaultImports?: boolean; - allowUnreachableCode?: boolean; - allowUnusedLabels?: boolean; - baseUrl?: string; - charset?: string; - declaration?: boolean; - declarationDir?: string; - disableSizeLimit?: boolean; - emitBOM?: boolean; - emitDecoratorMetadata?: boolean; - experimentalDecorators?: boolean; - forceConsistentCasingInFileNames?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - isolatedModules?: boolean; - jsx?: JsxEmit | ts.JsxEmit; - lib?: string[]; - locale?: string; - mapRoot?: string; - maxNodeModuleJsDepth?: number; - module?: ModuleKind | ts.ModuleKind; - moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; - newLine?: NewLineKind | ts.NewLineKind; - noEmit?: boolean; - noEmitHelpers?: boolean; - noEmitOnError?: boolean; - noErrorTruncation?: boolean; - noFallthroughCasesInSwitch?: boolean; - noImplicitAny?: boolean; - noImplicitReturns?: boolean; - noImplicitThis?: boolean; - noUnusedLocals?: boolean; - noUnusedParameters?: boolean; - noImplicitUseStrict?: boolean; - noLib?: boolean; - noResolve?: boolean; - out?: string; - outDir?: string; - outFile?: string; - paths?: MapLike; - preserveConstEnums?: boolean; - project?: string; - reactNamespace?: string; - removeComments?: boolean; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - sourceMap?: boolean; - sourceRoot?: string; - strictNullChecks?: boolean; - suppressExcessPropertyErrors?: boolean; - suppressImplicitAnyIndexErrors?: boolean; - target?: ScriptTarget | ts.ScriptTarget; - traceResolution?: boolean; - types?: string[]; - typeRoots?: string[]; - [option: string]: CompilerOptionsValue | undefined; - } - namespace JsxEmit { - type None = "None"; - type Preserve = "Preserve"; - type React = "React"; - } - type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; - namespace ModuleKind { - type None = "None"; - type CommonJS = "CommonJS"; - type AMD = "AMD"; - type UMD = "UMD"; - type System = "System"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; - namespace ModuleResolutionKind { - type Classic = "Classic"; - type Node = "Node"; - } - type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; - namespace NewLineKind { - type Crlf = "Crlf"; - type Lf = "Lf"; - } - type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; - namespace ScriptTarget { - type ES3 = "ES3"; - type ES5 = "ES5"; - type ES6 = "ES6"; - type ES2015 = "ES2015"; - } - type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; -} declare namespace ts.server { class ScriptInfo { private readonly host; @@ -3583,16 +10842,20 @@ declare namespace ts.server { private readonly resolvedModuleNames; private readonly resolvedTypeReferenceDirectives; private readonly getCanonicalFileName; + private filesWithChangedSetOfUnresolvedImports; private readonly resolveModuleName; readonly trace: (s: string) => void; + readonly realpath?: (path: string) => string; constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); - private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult); + startRecordingFilesWithChangedResolutions(): void; + finishRecordingFilesWithChangedResolutions(): Path[]; + 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[]; @@ -3612,22 +10875,19 @@ declare namespace ts.server { } declare namespace ts.server { interface ITypingsInstaller { - enqueueInstallTypingsRequest(p: Project, typingOptions: TypingOptions): void; + enqueueInstallTypingsRequest(p: Project, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray): void; attach(projectService: ProjectService): void; onProjectClosed(p: Project): void; readonly globalTypingsCacheLocation: string; } const nullTypingsInstaller: ITypingsInstaller; - interface TypingsArray extends ReadonlyArray { - " __typingsArrayBrand": any; - } class TypingsCache { private readonly installer; private readonly perProjectCache; constructor(installer: ITypingsInstaller); - getTypingsForProject(project: Project, forceRefresh: boolean): TypingsArray; - invalidateCachedTypingsForProject(project: Project): void; - updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typingOptions: TypingOptions, newTypings: string[]): void; + getTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray, forceRefresh: boolean): SortedReadonlyArray; + updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typingOptions: TypingOptions, unresolvedImports: SortedReadonlyArray, newTypings: string[]): void; + deleteTypingsForProject(projectName: string): void; onProjectClosed(project: Project): void; } } @@ -3663,6 +10923,15 @@ declare namespace ts.server { interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { projectErrors: Diagnostic[]; } + class UnresolvedImportsMap { + readonly perFileMap: FileMap>; + private version; + clear(): void; + getVersion(): number; + remove(path: Path): void; + get(path: Path): ReadonlyArray; + set(path: Path, value: ReadonlyArray): void; + } abstract class Project { readonly projectKind: ProjectKind; readonly projectService: ProjectService; @@ -3674,6 +10943,8 @@ declare namespace ts.server { private rootFilesMap; private lsHost; private program; + private cachedUnresolvedImportsPerFile; + private lastCachedUnresolvedImportsList; private languageService; builder: Builder; private lastReportedFileNames; @@ -3685,6 +10956,7 @@ declare namespace ts.server { typesVersion: number; isNonTsProject(): boolean; isJsOnlyProject(): boolean; + getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; constructor(projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); getProjectErrors(): Diagnostic[]; getLanguageService(ensureSynchronized?: boolean): LanguageService; @@ -3705,7 +10977,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; @@ -3713,6 +10985,7 @@ declare namespace ts.server { addRoot(info: ScriptInfo): void; removeFile(info: ScriptInfo, detachFromProject?: boolean): void; markAsDirty(): void; + private extractUnresolvedImportsFromSourceFile(file, result); updateGraph(): boolean; private setTypings(typings); private updateGraphWorker(); @@ -3727,11 +11000,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; @@ -3896,6 +11168,9 @@ declare namespace ts.server { fileName: NormalizedPath; project: Project; } + interface EventSender { + event(payload: any, eventName: string): void; + } namespace CommandNames { const Brace: protocol.CommandTypes.Brace; const BraceFull: protocol.CommandTypes.BraceFull; @@ -3967,7 +11242,7 @@ declare namespace ts.server { const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; } function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; - class Session { + class Session implements EventSender { private host; protected readonly typingsInstaller: ITypingsInstaller; private byteLength; @@ -4193,3 +11468,178 @@ declare namespace ts.server { lineCount(): number; } } +declare let debugObjectHost: any; +declare namespace ts { + interface ScriptSnapshotShim { + getText(start: number, end: number): string; + getLength(): number; + getChangeRange(oldSnapshot: ScriptSnapshotShim): string; + dispose?(): void; + } + interface Logger { + log(s: string): void; + trace(s: string): void; + error(s: string): void; + } + interface LanguageServiceShimHost extends Logger { + getCompilationSettings(): string; + getScriptFileNames(): string; + getScriptKind?(fileName: string): ScriptKind; + getScriptVersion(fileName: string): string; + getScriptSnapshot(fileName: string): ScriptSnapshotShim; + getLocalizedDiagnosticMessages(): string; + getCancellationToken(): HostCancellationToken; + getCurrentDirectory(): string; + getDirectories(path: string): string; + getDefaultLibFileName(options: string): string; + getNewLine?(): string; + getProjectVersion?(): string; + useCaseSensitiveFileNames?(): boolean; + getTypeRootsVersion?(): number; + readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; + readFile(path: string, encoding?: string): string; + fileExists(path: string): boolean; + getModuleResolutionsForFile?(fileName: string): string; + getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string; + directoryExists(directoryName: string): boolean; + } + interface CoreServicesShimHost extends Logger { + directoryExists(directoryName: string): boolean; + fileExists(fileName: string): boolean; + getCurrentDirectory(): string; + getDirectories(path: string): string; + readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; + readFile(fileName: string): string; + realpath?(path: string): string; + trace(s: string): void; + useCaseSensitiveFileNames?(): boolean; + } + interface IFileReference { + path: string; + position: number; + length: number; + } + interface ShimFactory { + registerShim(shim: Shim): void; + unregisterShim(shim: Shim): void; + } + interface Shim { + dispose(_dummy: any): void; + } + interface LanguageServiceShim extends Shim { + languageService: LanguageService; + dispose(_dummy: any): void; + refresh(throwOnError: boolean): void; + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): string; + getSemanticDiagnostics(fileName: string): string; + getCompilerOptionsDiagnostics(): string; + getSyntacticClassifications(fileName: string, start: number, length: number): string; + getSemanticClassifications(fileName: string, start: number, length: number): string; + getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string; + getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; + getCompletionsAtPosition(fileName: string, position: number): string; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; + getQuickInfoAtPosition(fileName: string, position: number): string; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; + getBreakpointStatementAtPosition(fileName: string, position: number): string; + getSignatureHelpItems(fileName: string, position: number): string; + getRenameInfo(fileName: string, position: number): string; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; + getDefinitionAtPosition(fileName: string, position: number): string; + getTypeDefinitionAtPosition(fileName: string, position: number): string; + getImplementationAtPosition(fileName: string, position: number): string; + getReferencesAtPosition(fileName: string, position: number): string; + findReferences(fileName: string, position: number): string; + getOccurrencesAtPosition(fileName: string, position: number): string; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; + getNavigationBarItems(fileName: string): string; + getNavigationTree(fileName: string): string; + getOutliningSpans(fileName: string): string; + getTodoComments(fileName: string, todoCommentDescriptors: string): string; + getBraceMatchingAtPosition(fileName: string, position: number): string; + getIndentationAtPosition(fileName: string, position: number, options: string): string; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: string): string; + getFormattingEditsForDocument(fileName: string, options: string): string; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string; + getDocCommentTemplateAtPosition(fileName: string, position: number): string; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; + getEmitOutput(fileName: string): string; + getEmitOutputObject(fileName: string): EmitOutput; + } + interface ClassifierShim extends Shim { + getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; + getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; + } + interface CoreServicesShim extends Shim { + getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; + getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; + getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; + getDefaultCompilationSettings(): string; + discoverTypings(discoverTypingsJson: string): string; + } + class LanguageServiceShimHostAdapter implements LanguageServiceHost { + private shimHost; + private files; + private loggingEnabled; + private tracingEnabled; + resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModuleFull[]; + resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[]; + directoryExists: (directoryName: string) => boolean; + constructor(shimHost: LanguageServiceShimHost); + log(s: string): void; + trace(s: string): void; + error(s: string): void; + getProjectVersion(): string; + getTypeRootsVersion(): number; + useCaseSensitiveFileNames(): boolean; + getCompilationSettings(): CompilerOptions; + getScriptFileNames(): string[]; + getScriptSnapshot(fileName: string): IScriptSnapshot; + getScriptKind(fileName: string): ScriptKind; + getScriptVersion(fileName: string): string; + getLocalizedDiagnosticMessages(): any; + getCancellationToken(): HostCancellationToken; + getCurrentDirectory(): string; + getDirectories(path: string): string[]; + getDefaultLibFileName(options: CompilerOptions): string; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[]; + readFile(path: string, encoding?: string): string; + fileExists(path: string): boolean; + } + class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { + private shimHost; + directoryExists: (directoryName: string) => boolean; + realpath: (path: string) => string; + useCaseSensitiveFileNames: boolean; + constructor(shimHost: CoreServicesShimHost); + readDirectory(rootDir: string, extensions: string[], exclude: string[], include: string[], depth?: number): string[]; + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + private readDirectoryFallback(rootDir, extension, exclude); + getDirectories(path: string): string[]; + } + function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { + message: string; + start: number; + length: number; + category: string; + code: number; + }[]; + class TypeScriptServicesFactory implements ShimFactory { + private _shims; + private documentRegistry; + getServicesVersion(): string; + createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim; + createClassifierShim(logger: Logger): ClassifierShim; + createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim; + close(): void; + registerShim(shim: Shim): void; + unregisterShim(shim: Shim): void; + } +} +declare namespace TypeScript.Services { + const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; +} +declare const toolsVersion = "2.2"; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 0a476fd3ed1..5506c0e0566 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -20,462 +20,19 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - 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["QualifiedName"] = 140] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; - 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["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["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; - 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["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; - 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["ExternalModuleReference"] = 241] = "ExternalModuleReference"; - 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["CaseClause"] = 249] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; - 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["SyntaxList"] = 286] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; - SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - 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; - (function (NodeFlags) { - NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Let"] = 1] = "Let"; - NodeFlags[NodeFlags["Const"] = 2] = "Const"; - NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; - NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; - NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; - 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["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; - NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; - NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; - (function (ModifierFlags) { - ModifierFlags[ModifierFlags["None"] = 0] = "None"; - ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; - ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; - ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; - ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; - ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; - ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; - ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; - ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; - ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; - ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; - ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; - ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; - ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; - })(ts.ModifierFlags || (ts.ModifierFlags = {})); - var ModifierFlags = ts.ModifierFlags; - (function (JsxFlags) { - JsxFlags[JsxFlags["None"] = 0] = "None"; - JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; - JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; - (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; - (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; - (function (FlowFlags) { - FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; - FlowFlags[FlowFlags["Start"] = 2] = "Start"; - FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; - FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; - FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; - FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; - FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; - FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["Label"] = 12] = "Label"; - FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; - })(ts.FlowFlags || (ts.FlowFlags = {})); - var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } 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; - (function (TypeFormatFlags) { - TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; - TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; - TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; - TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; - TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; - TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; - TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; - TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; - TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; - TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - (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; - (function (TypePredicateKind) { - TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; - TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; - })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); - var TypePredicateKind = ts.TypePredicateKind; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -488,179 +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; - (function (SymbolFlags) { - SymbolFlags[SymbolFlags["None"] = 0] = "None"; - SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; - SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; - SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; - SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; - SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; - SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; - SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; - SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; - SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; - SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; - SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; - SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; - SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; - SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; - SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; - SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; - SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; - SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; - SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; - SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; - SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; - SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; - SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; - SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; - SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; - SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; - SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; - SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; - SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; - SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; - SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; - SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; - SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; - SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; - SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; - SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; - SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; - SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; - SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; - SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; - NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; - NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; - NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; - (function (TypeFlags) { - TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["Void"] = 1024] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 4096] = "Null"; - TypeFlags[TypeFlags["Never"] = 8192] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 32768] = "Class"; - TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 524288] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; - TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; - TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; - TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; - TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; - TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; - TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; - TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; - TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; - (function (SignatureKind) { - SignatureKind[SignatureKind["Call"] = 0] = "Call"; - SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; - (function (IndexKind) { - IndexKind[IndexKind["String"] = 0] = "String"; - IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; - (function (SpecialPropertyAssignmentKind) { - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; - })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); - var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; + })(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"; @@ -668,266 +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; - (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; - (function (NewLineKind) { - NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; - NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; - })(ts.NewLineKind || (ts.NewLineKind = {})); - var NewLineKind = ts.NewLineKind; - (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; - (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; - (function (LanguageVariant) { - LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; - LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; - })(ts.LanguageVariant || (ts.LanguageVariant = {})); - var LanguageVariant = ts.LanguageVariant; - (function (DiagnosticStyle) { - DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; - DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; - })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); - var DiagnosticStyle = ts.DiagnosticStyle; - (function (WatchDirectoryFlags) { - WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; - WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; - })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); - var WatchDirectoryFlags = ts.WatchDirectoryFlags; - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; - CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; - CharacterCodes[CharacterCodes["space"] = 32] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; - CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; - CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; - CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; - CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; - CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; - CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; - CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["j"] = 106] = "j"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["B"] = 66] = "B"; - CharacterCodes[CharacterCodes["C"] = 67] = "C"; - CharacterCodes[CharacterCodes["D"] = 68] = "D"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["G"] = 71] = "G"; - CharacterCodes[CharacterCodes["H"] = 72] = "H"; - CharacterCodes[CharacterCodes["I"] = 73] = "I"; - CharacterCodes[CharacterCodes["J"] = 74] = "J"; - CharacterCodes[CharacterCodes["K"] = 75] = "K"; - CharacterCodes[CharacterCodes["L"] = 76] = "L"; - CharacterCodes[CharacterCodes["M"] = 77] = "M"; - CharacterCodes[CharacterCodes["N"] = 78] = "N"; - CharacterCodes[CharacterCodes["O"] = 79] = "O"; - CharacterCodes[CharacterCodes["P"] = 80] = "P"; - CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; - CharacterCodes[CharacterCodes["R"] = 82] = "R"; - CharacterCodes[CharacterCodes["S"] = 83] = "S"; - CharacterCodes[CharacterCodes["T"] = 84] = "T"; - CharacterCodes[CharacterCodes["U"] = 85] = "U"; - CharacterCodes[CharacterCodes["V"] = 86] = "V"; - CharacterCodes[CharacterCodes["W"] = 87] = "W"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; - (function (TransformFlags) { - TransformFlags[TransformFlags["None"] = 0] = "None"; - TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; - 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["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["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - 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["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["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["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; - })(ts.TransformFlags || (ts.TransformFlags = {})); - var TransformFlags = ts.TransformFlags; - (function (EmitFlags) { - EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; - EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; - EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; - EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; - EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; - EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; - EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; - EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; - EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; - EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; - EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; - EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; - EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; - EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; - EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; - EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; - EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; - EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; - EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; - EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; - EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; - EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.EmitFlags || (ts.EmitFlags = {})); - var EmitFlags = ts.EmitFlags; - (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; + })(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) { @@ -990,12 +137,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - (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; var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { @@ -1060,12 +201,6 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; - (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; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -1078,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++) { @@ -1337,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); } @@ -1373,6 +520,41 @@ var ts; return result; } ts.deduplicate = deduplicate; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function changesAffectModuleResolution(oldOptions, newOptions) { + return !oldOptions || + (oldOptions.module !== newOptions.module) || + (oldOptions.moduleResolution !== newOptions.moduleResolution) || + (oldOptions.noResolve !== newOptions.noResolve) || + (oldOptions.target !== newOptions.target) || + (oldOptions.noLib !== newOptions.noLib) || + (oldOptions.jsx !== newOptions.jsx) || + (oldOptions.allowJs !== newOptions.allowJs) || + (oldOptions.rootDir !== newOptions.rootDir) || + (oldOptions.configFilePath !== newOptions.configFilePath) || + (oldOptions.baseUrl !== newOptions.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) || + !arrayIsEqualTo(oldOptions.lib, newOptions.lib) || + !arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) || + !equalOwnProperties(oldOptions.paths, newOptions.paths); + } + ts.changesAffectModuleResolution = changesAffectModuleResolution; function compact(array) { var result; if (array) { @@ -1391,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++) { @@ -1400,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) { @@ -1427,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] @@ -1439,17 +655,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; + function replaceElement(array, index, value) { + var result = array.slice(0); + result[index] = value; + return result; } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value, comparer) { + ts.replaceElement = replaceElement; + 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 @@ -1683,6 +899,12 @@ var ts; return Array.isArray ? Array.isArray(value) : value instanceof Array; } ts.isArray = isArray; + function noop() { } + ts.noop = noop; + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; function memoize(callback) { var value; return function () { @@ -1798,6 +1020,17 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText + }; + } + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; function chainDiagnosticMessages(details, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -2190,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); } @@ -2217,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); } @@ -2345,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; } @@ -2413,14 +1670,6 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; - (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; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -2471,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); } @@ -2509,13 +1754,6 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; - (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; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2627,6 +1865,36 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + var ext = tryGetExtensionFromPath(path); + if (ext !== undefined) { + return ext; + } + Debug.fail("File " + path + " has unknown extension."); + } + ts.extensionFromPath = extensionFromPath; + function tryGetExtensionFromPath(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; + } + } + ts.tryGetExtensionFromPath = tryGetExtensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2900,11 +2168,6 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } - var FileSystemEntryKind; - (function (FileSystemEntryKind) { - FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; - FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; - })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2926,6 +2189,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, @@ -2935,7 +2199,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 { @@ -2943,7 +2207,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); } }; @@ -2958,7 +2222,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 }; @@ -3035,7 +2299,9 @@ var ts; } catch (e) { } - } + }, + setTimeout: setTimeout, + clearTimeout: clearTimeout }; return nodeSystem; } @@ -3153,7 +2419,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." }, @@ -3263,7 +2529,6 @@ var ts; Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, @@ -3381,14 +2646,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}'" }, @@ -3428,7 +2693,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" }, @@ -3466,8 +2731,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." }, @@ -3479,7 +2742,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." }, @@ -3501,9 +2764,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." }, @@ -3550,6 +2811,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." }, @@ -3573,6 +2841,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." }, @@ -3604,6 +2873,10 @@ 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." }, + An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, 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}'." }, @@ -3703,6 +2976,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." }, @@ -3786,7 +3060,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." }, @@ -3823,11 +3097,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." }, @@ -3836,7 +3115,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." }, @@ -3883,6 +3163,8 @@ var ts; Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, @@ -3890,4175 +3172,11 @@ var ts; Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, 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; -(function (ts) { - function trace(host) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - ts.trace = trace; - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - ts.createResolvedModule = createResolvedModule; - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - 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)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - 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 { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_1 = ts.getDirectoryPath(currentDirectory); - if (parent_1 === currentDirectory) { - break; - } - currentDirectory = parent_1; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - 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]; - 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) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = 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); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - 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]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - 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); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - 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); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - 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; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - 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); - } - } - 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) { - 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; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - 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) { - 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); - } - 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); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - 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); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, 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); - }); - } - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(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; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); - } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(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; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); - } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; - function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); - } - function loadModuleFromNodeModulesWorker(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; - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - 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 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) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - return referencedSourceFile; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - return undefined; - } - containingDirectory = parentPath; - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - var declaration = declarations_1[_i]; - if (declaration.kind === kind) { - return declaration; - } - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str_1 = ""; - var writeText = function (text) { return str_1 += text; }; - return { - string: function () { return str_1; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); - } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; - } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = ts.createMap(); - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; - } - ts.setResolvedModule = setResolvedModule; - function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { - if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); - } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; - } - ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; - } - ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; - } - ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { - if (names.length !== newResolutions.length) { - return false; - } - for (var i = 0; i < names.length; i++) { - var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; - var changed = oldResolution - ? !newResolution || !comparer(oldResolution, newResolution) - : newResolution; - if (changed) { - return true; - } - } - return false; - } - ts.hasChangesInResolutions = hasChangesInResolutions; - function containsParseError(node) { - aggregateChildData(node); - return (node.flags & 2097152) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; - } - node.flags |= 4194304; - } - } - function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function isStatementWithLocals(node) { - switch (node.kind) { - case 200: - case 228: - case 207: - case 208: - case 209: - return true; - } - return false; - } - ts.isStatementWithLocals = isStatementWithLocals; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = ts.getLineStarts(sourceFile); - var lineIndex = line; - var sourceText = sourceFile.text; - if (lineIndex + 1 === lineStarts.length) { - return sourceText.length - 1; - } - else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { - pos--; - } - return pos; - } - } - ts.getEndLinePosition = getEndLinePosition; - function nodeIsMissing(node) { - if (node === undefined) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; - } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); - } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { - if (nodeIsMissing(node)) { - return node.pos; - } - if (isJSDocNode(node)) { - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); - } - if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { - return getTokenPosOfNode(node.jsDocComments[0]); - } - if (node.kind === 286 && 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; - } - ts.isJSDocNode = isJSDocNode; - function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; - } - ts.isJSDocTag = isJSDocTag; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); - } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); - } - ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 15: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); - } - ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; - } - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); - } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclaration(declaration); - } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function isAmbientModule(node) { - return node && node.kind === 226 && - (node.name.kind === 9 || isGlobalScopeAugmentation(node)); - } - ts.isAmbientModule = isAmbientModule; - function isShorthandAmbientModuleSymbol(moduleSymbol) { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); - } - ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; - function isShorthandAmbientModule(node) { - return node.kind === 226 && (!node.body); - } - function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 226 || - isFunctionLike(node); - } - ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; - function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); - } - ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; - function isExternalModuleAugmentation(node) { - if (!node || !isAmbientModule(node)) { - return false; - } - switch (node.parent.kind) { - case 256: - return ts.isExternalModule(node.parent); - case 227: - return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); - } - return false; - } - 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 150: - case 151: - case 221: - case 180: - case 181: - return true; - case 200: - return parentNode && !isFunctionLike(parentNode); - } - return false; - } - ts.isBlockScope = isBlockScope; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - current = current.parent; - } - } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 219 && - declaration.parent && - declaration.parent.kind === 252; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); - } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForArrowFunction(sourceFile, node) { - var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200) { - var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; - if (startLine < endLine) { - return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); - } - } - return ts.createTextSpanFromBounds(pos, node.end); - } - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 256: - 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 225: - case 255: - case 221: - case 180: - case 148: - case 150: - case 151: - case 224: - errorNode = node.name; - break; - case 181: - return getErrorSpanForArrowFunction(sourceFile, node); - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalOrCommonJsModule(file) { - return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; - } - ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; - function isDeclarationFile(file) { - return file.isDeclarationFile; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 225 && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); - } - ts.isConst = isConst; - function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1); - } - ts.isLet = isLet; - function isSuperCall(n) { - return n.kind === 175 && n.expression.kind === 96; - } - ts.isSuperCall = isSuperCall; - function isPrologueDirective(node) { - return node.kind === 203 && node.expression.kind === 9; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); - } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJsDocComments(node, sourceFileOfNode) { - return getJsDocCommentsFromText(node, sourceFileOfNode.text); - } - ts.getJsDocComments = getJsDocComments; - function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 || - node.kind === 142 || - node.kind === 180 || - node.kind === 181) ? - ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 42 && - text.charCodeAt(comment.pos + 3) !== 47; - } - } - ts.getJsDocCommentsFromText = getJsDocCommentsFromText; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isPartOfTypeNode(node) { - if (155 <= node.kind && node.kind <= 167) { - return true; - } - switch (node.kind) { - case 118: - case 131: - case 133: - case 121: - case 134: - case 136: - case 128: - return true; - case 104: - return node.parent.kind !== 184; - case 195: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 140 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 173 && 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: - case 98: - var parent_2 = node.parent; - if (parent_2.kind === 159) { - return false; - } - if (155 <= parent_2.kind && parent_2.kind <= 167) { - return true; - } - switch (parent_2.kind) { - case 195: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 142: - return node === parent_2.constraint; - case 146: - case 145: - case 143: - case 219: - return node === parent_2.type; - case 221: - case 180: - case 181: - case 149: - case 148: - case 147: - case 150: - case 151: - return node === parent_2.type; - case 152: - case 153: - case 154: - return node === parent_2.type; - case 178: - return node === parent_2.type; - case 175: - case 176: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 177: - return false; - } - } - return false; - } - ts.isPartOfTypeNode = isPartOfTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 212: - return visitor(node); - case 228: - case 200: - case 204: - case 205: - case 206: - case 207: - case 208: - case 209: - case 213: - case 214: - case 249: - case 250: - case 215: - case 217: - case 252: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 191: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 225: - case 223: - case 226: - case 224: - case 222: - case 193: - return; - default: - if (isFunctionLike(node)) { - var name_4 = node.name; - if (name_4 && name_4.kind === 141) { - traverse(name_4.expression); - return; - } - } - else if (!isPartOfTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } - } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 170: - case 255: - case 143: - case 253: - case 146: - case 145: - case 254: - case 219: - return true; - } - } - return false; - } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 150 || node.kind === 151); - } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 222 || node.kind === 193); - } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); - } - ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { - switch (kind) { - case 149: - case 180: - case 221: - case 181: - case 148: - case 147: - case 150: - case 151: - case 152: - case 153: - case 154: - case 157: - case 158: - return true; - } - return false; - } - ts.isFunctionLikeKind = isFunctionLikeKind; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 148: - case 147: - case 149: - case 150: - case 151: - case 221: - case 180: - return true; - } - return false; - } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 207: - case 208: - case 209: - case 205: - case 206: - return true; - case 215: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - ts.isIterationStatement = isIterationStatement; - function isFunctionBlock(node) { - return node && node.kind === 200 && isFunctionLike(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 148 && node.parent.kind === 172; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 && - (node.parent.kind === 172 || - node.parent.kind === 193); - } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; - function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1; - } - ts.isIdentifierTypePredicate = isIdentifierTypePredicate; - function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0; - } - ts.isThisTypePredicate = isThisTypePredicate; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 141: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 181: - if (!includeArrowFunctions) { - continue; - } - case 221: - case 180: - case 226: - case 146: - case 145: - case 148: - case 147: - case 149: - case 150: - case 151: - case 152: - case 153: - case 154: - case 225: - case 256: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, stopOnFunctions) { - while (true) { - node = node.parent; - if (!node) { - return node; - } - switch (node.kind) { - case 141: - node = node.parent; - break; - case 221: - case 180: - case 181: - if (!stopOnFunctions) { - continue; - } - case 146: - case 145: - case 148: - case 147: - case 149: - case 150: - case 151: - return node; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 || func.kind === 181) { - var prev = func; - var parent_3 = func.parent; - while (parent_3.kind === 179) { - prev = parent_3; - parent_3 = parent_3.parent; - } - if (parent_3.kind === 175 && parent_3.expression === prev) { - return parent_3; - } - } - } - ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; - function isSuperProperty(node) { - var kind = node.kind; - return (kind === 173 || kind === 174) - && 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; - } - } - return undefined; - } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function isCallLikeExpression(node) { - switch (node.kind) { - case 175: - case 176: - case 177: - case 144: - return true; - default: - return false; - } - } - ts.isCallLikeExpression = isCallLikeExpression; - function getInvokedExpression(node) { - if (node.kind === 177) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 222: - return true; - case 146: - return node.parent.kind === 222; - case 150: - case 151: - case 148: - return node.body !== undefined - && node.parent.kind === 222; - case 143: - return node.parent.body !== undefined - && (node.parent.kind === 149 - || node.parent.kind === 148 - || node.parent.kind === 151) - && node.parent.parent.kind === 222; - } - return false; - } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - return node.decorators !== undefined - && nodeCanBeDecorated(node); - } - ts.nodeIsDecorated = nodeIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); - } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 222: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148: - case 151: - 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) { - return parent.tagName === node; - } - return false; - } - ts.isJSXTagName = isJSXTagName; - function isPartOfExpression(node) { - switch (node.kind) { - case 98: - case 96: - case 94: - 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 181: - case 184: - case 182: - case 183: - case 186: - case 187: - case 188: - case 189: - case 192: - case 190: - case 12: - case 194: - case 242: - case 243: - case 191: - case 185: - return true; - case 140: - while (node.parent.kind === 140) { - node = node.parent; - } - return node.parent.kind === 159 || isJSXTagName(node); - case 70: - if (node.parent.kind === 159 || isJSXTagName(node)) { - return true; - } - case 8: - case 9: - case 98: - var parent_4 = node.parent; - switch (parent_4.kind) { - case 219: - case 143: - case 146: - case 145: - case 255: - case 253: - case 170: - 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: - var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || - forInStatement.expression === node; - case 178: - case 196: - return node === parent_4.expression; - case 198: - return node === parent_4.expression; - case 141: - return node === parent_4.expression; - case 144: - case 248: - case 247: - return true; - case 195: - return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); - default: - if (isPartOfExpression(parent_4)) { - return true; - } - } - } - return false; - } - ts.isPartOfExpression = isPartOfExpression; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); - } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind === 241; - } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind !== 241; - } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function isSourceFileJavaScript(file) { - return isInJavaScriptFile(file); - } - ts.isSourceFileJavaScript = isSourceFileJavaScript; - function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); - } - ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 175 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); - } - ts.isRequireCall = isRequireCall; - function isSingleOrDoubleQuote(charCode) { - return charCode === 39 || charCode === 34; - } - ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219) { - var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180; - } - return false; - } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; - function getSpecialPropertyAssignmentKind(expression) { - if (!isInJavaScriptFile(expression)) { - return 0; - } - if (expression.kind !== 188) { - return 0; - } - var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { - return 0; - } - var lhs = expr.left; - if (lhs.expression.kind === 70) { - var lhsId = lhs.expression; - if (lhsId.text === "exports") { - return 1; - } - else if (lhsId.text === "module" && lhs.name.text === "exports") { - return 2; - } - } - else if (lhs.expression.kind === 98) { - return 4; - } - else if (lhs.expression.kind === 173) { - var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { - var innerPropertyAccessIdentifier = innerPropertyAccess.expression; - if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { - return 1; - } - if (innerPropertyAccess.name.text === "prototype") { - return 3; - } - } - } - return 0; - } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; - function getExternalModuleName(node) { - if (node.kind === 231) { - return node.moduleSpecifier; - } - if (node.kind === 230) { - var reference = node.moduleReference; - if (reference.kind === 241) { - return reference.expression; - } - } - if (node.kind === 237) { - return node.moduleSpecifier; - } - if (node.kind === 226 && node.name.kind === 9) { - return node.name; - } - } - ts.getExternalModuleName = getExternalModuleName; - function getNamespaceDeclarationNode(node) { - if (node.kind === 230) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { - return importClause.namedBindings; - } - } - ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; - function isDefaultImport(node) { - return node.kind === 231 - && node.importClause - && !!node.importClause.name; - } - ts.isDefaultImport = isDefaultImport; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 143: - case 148: - case 147: - case 254: - case 253: - case 146: - case 145: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 269 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 271; - } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind, checkParentVariableStatement) { - if (!node) { - return undefined; - } - var jsDocTags = getJSDocTags(node, checkParentVariableStatement); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { - var tag = jsDocTags_1[_i]; - if (tag.kind === kind) { - return tag; - } - } - } - function append(previous, additional) { - if (additional) { - if (!previous) { - previous = []; - } - for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { - var x = additional_1[_i]; - previous.push(x); - } - } - return previous; - } - function getJSDocComments(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); - } - ts.getJSDocComments = getJSDocComments; - function getJSDocTags(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { - var result = []; - for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { - var doc = docs_1[_i]; - if (doc.tags) { - result.push.apply(result, doc.tags); - } - } - return result; - }, function (tags) { return tags; }); - } - function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { - var result = undefined; - if (checkParentVariableStatement) { - var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && - (node.parent).initializer === node && - node.parent.parent.parent.kind === 201; - var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201; - 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) { - 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.operatorToken.kind === 57 && - parent_5.parent.kind === 203; - if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); - } - var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; - if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 143) { - var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); - if (paramTags) { - result = append(result, getTags(paramTags)); - } - } - } - if (isVariableLike(node) && node.initializer) { - result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); - } - if (node.jsDocComments) { - if (result) { - result = append(result, getDocs(node.jsDocComments)); - } - else { - return getDocs(node.jsDocComments); - } - } - return result; - } - function getJSDocParameterTag(param, checkParentVariableStatement) { - var func = param.parent; - 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; }); - if (paramTags && 0 <= i && i < paramTags.length) { - return [paramTags[i]]; - } - } - else if (param.name.kind === 70) { - var name_5 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_5; }); - if (paramTags) { - return paramTags; - } - } - else { - return undefined; - } - } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); - } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 70) { - var parameterName = parameter.name.text; - var jsDocTags = getJSDocTags(parameter.parent, true); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { - var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { - var parameterTag = tag; - if (parameterTag.parameterName.text === parameterName) { - return parameterTag; - } - } - } - } - return undefined; - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); - } - ts.hasRestParameter = hasRestParameter; - function hasDeclaredRestParameter(s) { - return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); - } - ts.hasDeclaredRestParameter = hasDeclaredRestParameter; - function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; - } - } - return isDeclaredRestParam(node); - } - ts.isRestParameter = isRestParameter; - function isDeclaredRestParam(node) { - return node && node.dotDotDotToken !== undefined; - } - ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 179) { - node = node.parent; - } - while (true) { - var parent_6 = node.parent; - if (parent_6.kind === 171 || parent_6.kind === 192) { - node = parent_6; - continue; - } - 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; - } - } - ts.isAssignmentTarget = isAssignmentTarget; - function isNodeDescendantOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - ts.isNodeDescendantOf = isNodeDescendantOf; - function isInAmbientContext(node) { - while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { - return true; - } - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 235 || parent.kind === 239) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; - } - ts.isDeclarationName = isDeclarationName; - function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 141 && - 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 151: - case 255: - case 253: - case 173: - return parent.name === node; - case 140: - if (parent.right === node) { - while (parent.kind === 140) { - parent = parent.parent; - } - return parent.kind === 159; - } - return false; - case 170: - case 235: - return parent.propertyName === node; - case 239: - 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); - } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - return isEntityNameExpression(node.expression); - } - ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { - var clause = clauses_1[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - return host.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.test(comment)) { - if (isNoDefaultLibRegEx.test(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); - if (refMatchResult || refLibResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: (refMatchResult || refLibResult)[3] - }, - isNoDefaultLib: false, - isTypeReferenceDirective: !!refLibResult - }; - } - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 71 <= token && token <= 139; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); - } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(kind) { - return kind === 9 || kind === 8; - } - ts.isStringOrNumericLiteral = isStringOrNumericLiteral; - function hasDynamicName(declaration) { - return declaration.name && isDynamicName(declaration.name); - } - ts.hasDynamicName = hasDynamicName; - function isDynamicName(name) { - return name.kind === 141 && - !isStringOrNumericLiteral(name.expression.kind) && - !isWellKnownSymbolSyntactically(name.expression); - } - ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { - return name.text; - } - if (name.kind === 141) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - else if (nameExpression.kind === 9 || nameExpression.kind === 8) { - return nameExpression.text; - } - } - return undefined; - } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; - } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isPushOrUnshiftIdentifier(node) { - return node.text === "push" || node.text === "unshift"; - } - ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; - function isModifierKind(token) { - switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 129: - case 114: - return true; - } - return false; - } - ts.isModifierKind = isModifierKind; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 143; - } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 170) { - node = node.parent.parent; - } - return node; - } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(node) { - var kind = node.kind; - return kind === 149 - || kind === 180 - || kind === 221 - || kind === 181 - || kind === 148 - || kind === 150 - || kind === 151 - || kind === 226 - || kind === 256; - } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); - } - ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } - } - return node; - } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; - } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; - } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; - } - return undefined; - } - ts.getParseTreeNode = getParseTreeNode; - function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); - } - } - return originalSourceFiles; - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; - function getOriginalNodeId(node) { - node = getOriginalNode(node); - return node ? ts.getNodeId(node) : 0; - } - ts.getOriginalNodeId = getOriginalNodeId; - (function (Associativity) { - Associativity[Associativity["Left"] = 0] = "Left"; - Associativity[Associativity["Right"] = 1] = "Right"; - })(ts.Associativity || (ts.Associativity = {})); - var Associativity = ts.Associativity; - function getExpressionAssociativity(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; - return getOperatorAssociativity(expression.kind, operator, hasArguments); - } - ts.getExpressionAssociativity = getExpressionAssociativity; - function getOperatorAssociativity(kind, operator, hasArguments) { - switch (kind) { - case 176: - return hasArguments ? 0 : 1; - case 186: - case 183: - case 184: - case 182: - case 185: - case 189: - case 191: - return 1; - case 188: - switch (operator) { - case 39: - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 1; - } - } - return 0; - } - ts.getOperatorAssociativity = getOperatorAssociativity; - function getExpressionPrecedence(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; - return getOperatorPrecedence(expression.kind, operator, hasArguments); - } - ts.getExpressionPrecedence = getExpressionPrecedence; - function getOperator(expression) { - if (expression.kind === 188) { - return expression.operatorToken.kind; - } - else if (expression.kind === 186 || expression.kind === 187) { - return expression.operator; - } - else { - return expression.kind; - } - } - ts.getOperator = getOperator; - function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { - switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - 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 182: - case 185: - return 15; - case 188: - switch (operatorKind) { - case 50: - case 51: - return 15; - case 39: - case 38: - case 40: - case 41: - return 14; - case 36: - case 37: - return 13; - case 44: - case 45: - case 46: - return 12; - case 26: - case 29: - case 28: - case 30: - case 91: - case 92: - return 11; - case 31: - case 33: - case 32: - case 34: - return 10; - case 47: - return 9; - case 49: - return 8; - case 48: - return 7; - case 52: - return 6; - case 53: - return 5; - case 57: - case 58: - case 59: - case 61: - case 60: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 69: - case 68: - return 3; - case 25: - return 0; - default: - return -1; - } - case 189: - return 4; - case 191: - return 2; - case 192: - return 1; - default: - return -1; - } - } - ts.getOperatorPrecedence = getOperatorPrecedence; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = ts.createMap(); - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; - } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; - } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } - } - else { - diagnostics = nonFileDiagnostics; - } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; - } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } - } - } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }); - function escapeString(s) { - s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; - return s; - function getReplacement(c) { - return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); - } - } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; - } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; - } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; - } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output; - var indent; - var lineStart; - var lineCount; - var linePos; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function reset() { - output = ""; - indent = 0; - lineStart = true; - lineCount = 0; - linePos = 0; - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(text, node) { - write(getTextOfNodeFromSourceText(text, node)); - } - reset(); - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; }, - isAtStartOfLine: function () { return lineStart; }, - reset: reset - }; - } - ts.createTextWriter = createTextWriter; - function getResolvedExternalModuleName(host, file) { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); - } - ts.getResolvedExternalModuleName = getResolvedExternalModuleName; - function getExternalModuleNameFromDeclaration(host, resolver, declaration) { - var file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { - return undefined; - } - return getResolvedExternalModuleName(host, file); - } - ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; - function getExternalModuleNameFromPath(host, fileName) { - var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); - var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); - return ts.removeFileExtension(relativePath); - } - ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); - } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); - } - return emitOutputFilePathWithoutExtension + extension; - } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getDeclarationEmitOutputFilePath(sourceFile, host) { - var options = host.getCompilerOptions(); - var outputDir = options.declarationDir || options.outDir; - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } - ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getSourceFilesToEmit(host, targetSourceFile) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); - } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, isNonDeclarationFile); - } - } - ts.getSourceFilesToEmit = getSourceFilesToEmit; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); - } - function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); - } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(sourceFiles); - } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); - } - function onBundledEmit(sourceFiles) { - if (sourceFiles.length) { - var jsFilePath = options.outFile || options.out; - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); - } - } - } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; - function getSourceMapFilePath(jsFilePath, options) { - return options.sourceMap ? jsFilePath + ".map" : undefined; - } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); - } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } - } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } - } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; - } - } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); - } - } - } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - var commonSourceDirectory = host.getCommonSourceDirectory(); - var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; - sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; - } - ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 149 && nodeIsPresent(member.body)) { - return member; - } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); - return accessor.parameters[hasThis ? 1 : 0].type; - } - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function getThisParameter(signature) { - if (signature.parameters.length) { - var thisParameter = signature.parameters[0]; - if (parameterIsThisKeyword(thisParameter)) { - return thisParameter; - } - } - } - ts.getThisParameter = getThisParameter; - function parameterIsThisKeyword(parameter) { - return isThisIdentifier(parameter.name); - } - ts.parameterIsThisKeyword = parameterIsThisKeyword; - function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); - } - ts.isThisIdentifier = isThisIdentifier; - function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; - } - ts.identifierIsThisKeyword = identifierIsThisKeyword; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 150) { - getAccessor = accessor; - } - else if (accessor.kind === 151) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 150 || member.kind === 151) - && hasModifier(member, 32) === hasModifier(accessor, 32)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 150 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 151 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { - emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { - if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { - if (pos !== commentPos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; - function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { - if (comments && comments.length > 0) { - if (leadingSeparator) { - writer.write(" "); - } - var emitInterveningSeparator = false; - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - if (emitInterveningSeparator) { - writer.write(" "); - emitInterveningSeparator = false; - } - writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else { - emitInterveningSeparator = true; - } - } - if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); - } - } - } - ts.emitComments = emitComments; - function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { - var leadingComments; - var currentDetachedCommentInfo; - if (removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); - } - } - else { - leadingComments = ts.getLeadingCommentRanges(text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment = void 0; - for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { - var comment = leadingComments_1[_i]; - if (lastComment) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); - var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); - if (commentLine >= lastCommentLine + 2) { - break; - } - } - detachedComments.push(comment); - lastComment = comment; - } - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); - var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); - emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - } - } - } - return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; - } - } - ts.emitDetachedComments = emitDetachedComments; - function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42) { - var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); - var lineCount = lineMap.length; - var firstCommentLineIndent = void 0; - for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? text.length + 1 - : lineMap[currentLine + 1]; - if (pos !== commentPos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(text.substring(commentPos, commentEnd)); - } - } - ts.writeCommentRange = writeCommentRange; - function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { - var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== commentEnd) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(text, pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - function hasModifiers(node) { - return getModifierFlags(node) !== 0; - } - ts.hasModifiers = hasModifiers; - function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; - } - ts.hasModifier = hasModifier; - function getModifierFlags(node) { - if (node.modifierFlagsCache & 536870912) { - return node.modifierFlagsCache & ~536870912; - } - var flags = 0; - if (node.modifiers) { - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - flags |= modifierToFlag(modifier.kind); - } - } - if (node.flags & 4) { - flags |= 1; - } - node.modifierFlagsCache = flags | 536870912; - return flags; - } - ts.getModifierFlags = getModifierFlags; - function modifierToFlag(token) { - switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 129: return 64; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; - } - ts.isLogicalOperator = isLogicalOperator; - function isAssignmentOperator(token) { - return token >= 57 && token <= 69; - } - ts.isAssignmentOperator = isAssignmentOperator; - function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 && - node.parent.token === 84 && - isClassLike(node.parent.parent)) { - return node.parent.parent; - } - } - ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isDestructuringAssignment(node) { - if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 57) { - var kind = node.left.kind; - return kind === 172 - || kind === 171; - } - } - return false; - } - ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 173 && 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); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 172) { - return expression.properties.length === 0; - } - if (kind === 171) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function tryExtractTypeScriptExtension(fileName) { - return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - ts.stringify = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify - : stringifyFallback; - function stringifyFallback(value) { - return value === undefined ? undefined : stringifyValue(value); - } - function stringifyValue(value) { - return typeof value === "string" ? "\"" + escapeString(value) + "\"" - : typeof value === "number" ? isFinite(value) ? String(value) : "null" - : typeof value === "boolean" ? value ? "true" : "false" - : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) - : "null"; - } - function cycleCheck(cb, value) { - ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); - value.__cycle = true; - var result = cb(value); - delete value.__cycle; - return result; - } - function stringifyArray(value) { - return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; - } - function stringifyElement(memo, value) { - return (memo ? memo + "," : memo) + stringifyValue(value); - } - function stringifyObject(value) { - return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; - } - function stringifyProperty(memo, value, key) { - return value === undefined || typeof value === "function" || key === "__cycle" ? memo - : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 11 - || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { - return true; - } - else if (kind === 173) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 174) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 186 - || kind === 187) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 188) { - return node.operatorToken.kind !== 39 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 189) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 184 - || kind === 183 - || kind === 182) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 171) { - return node.elements.length === 0; - } - else if (kind === 172) { - return node.properties.length === 0; - } - else if (kind === 175) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } - var syntaxKindCache = ts.createMap(); - function formatSyntaxKind(kind) { - var syntaxKindEnum = ts.SyntaxKind; - if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; - } - for (var name_6 in syntaxKindEnum) { - if (syntaxKindEnum[name_6] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_6 + ")"; - } - } - } - else { - return kind.toString(); - } - } - ts.formatSyntaxKind = formatSyntaxKind; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; - function createRange(pos, end) { - return { pos: pos, end: end }; - } - ts.createRange = createRange; - function moveRangeEnd(range, end) { - return createRange(range.pos, end); - } - ts.moveRangeEnd = moveRangeEnd; - function moveRangePos(range, pos) { - return createRange(pos, range.end); - } - ts.moveRangePos = moveRangePos; - function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) - : node; - } - ts.moveRangePastDecorators = moveRangePastDecorators; - function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) - : moveRangePastDecorators(node); - } - ts.moveRangePastModifiers = moveRangePastModifiers; - function isCollapsedRange(range) { - return range.pos === range.end; - } - ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; - function createTokenRange(pos, token) { - return createRange(pos, pos + ts.tokenToString(token).length); - } - ts.createTokenRange = createTokenRange; - function rangeIsOnSingleLine(range, sourceFile) { - return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); - } - ts.rangeIsOnSingleLine = rangeIsOnSingleLine; - function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; - function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, range2.end, sourceFile); - } - ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; - function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); - } - ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; - function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; - function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); - } - ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); - } - ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { - var externalImports = []; - var exportSpecifiers = ts.createMap(); - 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: - externalImports.push(node); - break; - case 230: - if (node.moduleReference.kind === 241) { - externalImports.push(node); - } - break; - case 237: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } - else { - externalImports.push(node); - } - } - else { - for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { - var specifier = _c[_b]; - var name_7 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_7] || (exportSpecifiers[name_7] = [])).push(specifier); - } - } - break; - case 236: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; - } - ts.collectExternalModuleInfo = collectExternalModuleInfo; - function getInitializedVariables(node) { - return ts.filter(node.declarations, isInitializedVariable); - } - ts.getInitializedVariables = getInitializedVariables; - function isInitializedVariable(node) { - return node.initializer !== undefined; - } - function isMergedWithClass(node) { - 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) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; - function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - ts.isNodeArray = isNodeArray; - function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; - } - ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isLiteralExpression(node) { - return isLiteralKind(node.kind); - } - ts.isLiteralExpression = isLiteralExpression; - function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateHead(node) { - return node.kind === 13; - } - ts.isTemplateHead = isTemplateHead; - function isTemplateMiddleOrTemplateTail(node) { - var kind = node.kind; - return kind === 14 - || kind === 15; - } - ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; - function isIdentifier(node) { - return node.kind === 70; - } - ts.isIdentifier = isIdentifier; - function isGeneratedIdentifier(node) { - return isIdentifier(node) && node.autoGenerateKind > 0; - } - ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isModifier(node) { - return isModifierKind(node.kind); - } - ts.isModifier = isModifier; - function isQualifiedName(node) { - return node.kind === 140; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 141; - } - ts.isComputedPropertyName = isComputedPropertyName; - function isEntityName(node) { - var kind = node.kind; - return kind === 140 - || kind === 70; - } - ts.isEntityName = isEntityName; - function isPropertyName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9 - || kind === 8 - || kind === 141; - } - ts.isPropertyName = isPropertyName; - function isModuleName(node) { - var kind = node.kind; - return kind === 70 - || kind === 9; - } - ts.isModuleName = isModuleName; - function isBindingName(node) { - var kind = node.kind; - return kind === 70 - || kind === 168 - || kind === 169; - } - ts.isBindingName = isBindingName; - function isTypeParameter(node) { - return node.kind === 142; - } - ts.isTypeParameter = isTypeParameter; - function isParameter(node) { - return node.kind === 143; - } - ts.isParameter = isParameter; - function isDecorator(node) { - return node.kind === 144; - } - ts.isDecorator = isDecorator; - function isMethodDeclaration(node) { - return node.kind === 148; - } - ts.isMethodDeclaration = isMethodDeclaration; - function isClassElement(node) { - var kind = node.kind; - return kind === 149 - || kind === 146 - || kind === 148 - || kind === 150 - || kind === 151 - || kind === 154 - || kind === 199; - } - ts.isClassElement = isClassElement; - function isObjectLiteralElementLike(node) { - var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 148 - || kind === 150 - || kind === 151 - || kind === 240; - } - ts.isObjectLiteralElementLike = isObjectLiteralElementLike; - function isTypeNodeKind(kind) { - return (kind >= 155 && kind <= 167) - || kind === 118 - || kind === 131 - || kind === 121 - || kind === 133 - || kind === 134 - || kind === 104 - || kind === 128 - || kind === 195; - } - function isTypeNode(node) { - return isTypeNodeKind(node.kind); - } - ts.isTypeNode = isTypeNode; - function isBindingPattern(node) { - if (node) { - var kind = node.kind; - return kind === 169 - || kind === 168; - } - return false; - } - ts.isBindingPattern = isBindingPattern; - function isBindingElement(node) { - return node.kind === 170; - } - ts.isBindingElement = isBindingElement; - function isArrayBindingElement(node) { - var kind = node.kind; - return kind === 170 - || kind === 194; - } - ts.isArrayBindingElement = isArrayBindingElement; - function isPropertyAccessExpression(node) { - return node.kind === 173; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 174; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isBinaryExpression(node) { - return node.kind === 188; - } - ts.isBinaryExpression = isBinaryExpression; - function isConditionalExpression(node) { - return node.kind === 189; - } - ts.isConditionalExpression = isConditionalExpression; - function isCallExpression(node) { - return node.kind === 175; - } - ts.isCallExpression = isCallExpression; - function isTemplateLiteral(node) { - var kind = node.kind; - return kind === 190 - || kind === 12; - } - ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192; - } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { - return node.kind === 195; - } - ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; - function isLeftHandSideExpressionKind(kind) { - return kind === 173 - || kind === 174 - || kind === 176 - || kind === 175 - || kind === 242 - || kind === 243 - || kind === 177 - || kind === 171 - || kind === 179 - || kind === 172 - || kind === 193 - || kind === 180 - || kind === 70 - || kind === 11 - || kind === 8 - || kind === 9 - || kind === 12 - || kind === 190 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 197; - } - 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 - || kind === 185 - || kind === 178 - || isLeftHandSideExpressionKind(kind); - } - function isUnaryExpression(node) { - return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isUnaryExpression = isUnaryExpression; - function isExpressionKind(kind) { - return kind === 189 - || kind === 191 - || kind === 181 - || kind === 188 - || kind === 192 - || kind === 196 - || kind === 194 - || isUnaryExpressionKind(kind); - } - function isExpression(node) { - return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isExpression = isExpression; - function isAssertionExpression(node) { - var kind = node.kind; - return kind === 178 - || kind === 196; - } - ts.isAssertionExpression = isAssertionExpression; - function isPartiallyEmittedExpression(node) { - return node.kind === 288; - } - ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; - function isNotEmittedStatement(node) { - return node.kind === 287; - } - ts.isNotEmittedStatement = isNotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node) { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; - function isOmittedExpression(node) { - return node.kind === 194; - } - ts.isOmittedExpression = isOmittedExpression; - function isTemplateSpan(node) { - return node.kind === 198; - } - ts.isTemplateSpan = isTemplateSpan; - function isBlock(node) { - return node.kind === 200; - } - ts.isBlock = isBlock; - function isConciseBody(node) { - return isBlock(node) - || isExpression(node); - } - ts.isConciseBody = isConciseBody; - function isFunctionBody(node) { - return isBlock(node); - } - ts.isFunctionBody = isFunctionBody; - function isForInitializer(node) { - return isVariableDeclarationList(node) - || isExpression(node); - } - ts.isForInitializer = isForInitializer; - function isVariableDeclaration(node) { - return node.kind === 219; - } - ts.isVariableDeclaration = isVariableDeclaration; - function isVariableDeclarationList(node) { - return node.kind === 220; - } - ts.isVariableDeclarationList = isVariableDeclarationList; - function isCaseBlock(node) { - return node.kind === 228; - } - ts.isCaseBlock = isCaseBlock; - function isModuleBody(node) { - var kind = node.kind; - return kind === 227 - || kind === 226; - } - ts.isModuleBody = isModuleBody; - function isImportEqualsDeclaration(node) { - return node.kind === 230; - } - ts.isImportEqualsDeclaration = isImportEqualsDeclaration; - function isImportClause(node) { - return node.kind === 232; - } - ts.isImportClause = isImportClause; - function isNamedImportBindings(node) { - var kind = node.kind; - return kind === 234 - || kind === 233; - } - ts.isNamedImportBindings = isNamedImportBindings; - function isImportSpecifier(node) { - return node.kind === 235; - } - ts.isImportSpecifier = isImportSpecifier; - function isNamedExports(node) { - return node.kind === 238; - } - ts.isNamedExports = isNamedExports; - function isExportSpecifier(node) { - return node.kind === 239; - } - ts.isExportSpecifier = isExportSpecifier; - function isModuleOrEnumDeclaration(node) { - return node.kind === 226 || node.kind === 225; - } - ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; - function isDeclarationKind(kind) { - return kind === 181 - || kind === 170 - || kind === 222 - || kind === 193 - || kind === 149 - || kind === 225 - || kind === 255 - || kind === 239 - || kind === 221 - || kind === 180 - || 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 === 224 - || kind === 142 - || kind === 219 - || kind === 279; - } - function isDeclarationStatementKind(kind) { - return kind === 221 - || kind === 240 - || kind === 222 - || kind === 223 - || kind === 224 - || kind === 225 - || kind === 226 - || kind === 231 - || kind === 230 - || kind === 237 - || kind === 236 - || kind === 229; - } - 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 - || kind === 213 - || kind === 287; - } - function isDeclaration(node) { - return isDeclarationKind(node.kind); - } - ts.isDeclaration = isDeclaration; - function isDeclarationStatement(node) { - return isDeclarationStatementKind(node.kind); - } - ts.isDeclarationStatement = isDeclarationStatement; - function isStatementButNotDeclaration(node) { - return isStatementKindButNotDeclarationKind(node.kind); - } - ts.isStatementButNotDeclaration = isStatementButNotDeclaration; - function isStatement(node) { - var kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === 200; - } - ts.isStatement = isStatement; - function isModuleReference(node) { - var kind = node.kind; - return kind === 241 - || kind === 140 - || kind === 70; - } - ts.isModuleReference = isModuleReference; - function isJsxOpeningElement(node) { - return node.kind === 244; - } - ts.isJsxOpeningElement = isJsxOpeningElement; - function isJsxClosingElement(node) { - return node.kind === 245; - } - ts.isJsxClosingElement = isJsxClosingElement; - function isJsxTagNameExpression(node) { - var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 173; - } - ts.isJsxTagNameExpression = isJsxTagNameExpression; - function isJsxChild(node) { - var kind = node.kind; - return kind === 242 - || kind === 248 - || kind === 243 - || kind === 10; - } - ts.isJsxChild = isJsxChild; - function isJsxAttributeLike(node) { - var kind = node.kind; - return kind === 246 - || kind === 247; - } - ts.isJsxAttributeLike = isJsxAttributeLike; - function isJsxSpreadAttribute(node) { - return node.kind === 247; - } - ts.isJsxSpreadAttribute = isJsxSpreadAttribute; - function isJsxAttribute(node) { - return node.kind === 246; - } - ts.isJsxAttribute = isJsxAttribute; - function isStringLiteralOrJsxExpression(node) { - var kind = node.kind; - return kind === 9 - || kind === 248; - } - ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; - function isCaseOrDefaultClause(node) { - var kind = node.kind; - return kind === 249 - || kind === 250; - } - ts.isCaseOrDefaultClause = isCaseOrDefaultClause; - function isHeritageClause(node) { - return node.kind === 251; - } - ts.isHeritageClause = isHeritageClause; - function isCatchClause(node) { - return node.kind === 252; - } - ts.isCatchClause = isCatchClause; - function isPropertyAssignment(node) { - return node.kind === 253; - } - ts.isPropertyAssignment = isPropertyAssignment; - function isShorthandPropertyAssignment(node) { - return node.kind === 254; - } - ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; - function isEnumMember(node) { - return node.kind === 255; - } - ts.isEnumMember = isEnumMember; - function isSourceFile(node) { - return node.kind === 256; - } - ts.isSourceFile = isSourceFile; - function isWatchSet(options) { - return options.watch && options.hasOwnProperty("watch"); - } - ts.isWatchSet = isWatchSet; -})(ts || (ts = {})); -(function (ts) { - function getDefaultLibFileName(options) { - switch (options.target) { - case 4: - return "lib.es2017.d.ts"; - case 3: - return "lib.es2016.d.ts"; - case 2: - return "lib.es6.d.ts"; - default: - return "lib.d.ts"; - } - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); - } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); - } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); - } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); - } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 142) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { - return current; - } - } - } - } - ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); - } - ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 || ts.isBindingPattern(node))) { - node = node.parent; - } - return node; - } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 219) { - node = node.parent; - } - if (node && node.kind === 220) { - flags |= ts.getModifierFlags(node); - node = node.parent; - } - if (node && node.kind === 201) { - flags |= ts.getModifierFlags(node); - } - return flags; - } - ts.getCombinedModifierFlags = getCombinedModifierFlags; - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 219) { - node = node.parent; - } - if (node && node.kind === 220) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 201) { - flags |= node.flags; - } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; -})(ts || (ts = {})); -var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { return token >= 70; @@ -8088,7 +3206,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -8098,34 +3216,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, @@ -8133,7 +3252,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -8228,8 +3347,8 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_8 in source) { - result[source[name_8]] = name_8; + for (var name_4 in source) { + result[source[name_4]] = name_4; } return result; } @@ -9516,10 +4635,13 @@ var ts; case 44: pos++; return token = 25; + case 46: + 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; @@ -9607,11 +4729,5885 @@ var ts; ts.createScanner = createScanner; })(ts || (ts = {})); var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMap({ + "preserve": 1, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + }, + { + name: "reactNamespace", + 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", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMap({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMap({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_in_the_given_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMap({ + "es3": 0, + "es5": 1, + "es6": 2, + "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, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMap({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMap({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.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.string": "lib.es2017.string.d.ts", + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + } + ]; + ts.typingOptionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } + } + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + var key = trimString((value || "")).toLowerCase(); + var map = opt.type; + if (key in map) { + return map[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + if (s in shortOptionNames) { + s = shortOptionNames[s]; + } + if (s in optionNameMap) { + var opt = optionNameMap[s]; + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } + } + } + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + for (var key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; + } + } + return undefined; + } + function serializeCompilerOptions(options) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name_5 in options) { + if (ts.hasProperty(options, name_5)) { + switch (name_5) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name_5]; + var optionDefinition = optionsNameMap[name_5.toLowerCase()]; + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name_5] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name_5] = convertedValue; + } + else { + result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + var errors = []; + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typingOptions: typingOptions, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); + } + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); + } + } + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + 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; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (id in optionNameMap) { + var opt = optionNameMap[id]; + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + } + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + if (key in opt.type) { + return opt.type[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap[keyMapper(file)] = file; + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { + wildcardFileMap[key] = file; + } + } + } + var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); + var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); + wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { + var spec = specs_2[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = ts.createMap(); + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { + continue; + } + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); + if (match) { + var key = match.key, flags = match.flags; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } + } + } + for (var key in wildcardDirectories) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } + } + } + } + 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); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + return true; + } + } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + delete wildcardFiles[lowerPriorityPath]; + } + } + function addFileToOutput(output, file) { + output.push(file); + return output; + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); + } +})(ts || (ts = {})); +var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, unresolvedImports) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } + } + } + 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++) { + var excludeTypingName = exclude_1[_b]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventInstall = "event::install"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +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"; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typingOptions, unresolvedImports, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(true), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + unresolvedImports: unresolvedImports, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; }, + startRecordingFilesWithChangedResolutions: function () { return undefined; }, + finishRecordingFilesWithChangedResolutions: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + function toSortedReadonlyArray(arr) { + arr.sort(); + return arr; + } + server.toSortedReadonlyArray = toSortedReadonlyArray; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function trace(host) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + 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 }; + } + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + 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 = 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); + } + return typesFilePath; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + }); + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + } + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + } + function secondaryLookup() { + var resolvedFile; + 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 = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + if (!resolvedFile && traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + } + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + 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]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); + } + else { + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); + } + } + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + 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(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, false, state); + return path_1 && { path: path_1, extension: tsExtension }; + } + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + 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(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + 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, 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); + } + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state); + return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, isExternalLibraryImport: true }; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; + } + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + 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 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(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + 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, failedLookupLocations, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + 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, failedLookupLocations, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocations.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var fromFile = tryFile(typesFile, failedLookupLocations, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); + if (x) { + return x; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocations.push(packageJsonPath); + } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + 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)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + } + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); + } + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); + } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); + } + }); + } + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== 1) { + return loadModuleFromNodeModulesFolder(2, 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 }; + var failedLookupLocations = []; + var containingDirectory = ts.getDirectoryPath(containingFile); + 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 = forEachAncestorDirectory(containingDirectory, function (directory) { + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, 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); + } + } + } + ts.classicNameResolver = classicNameResolver; + 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 = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.externalHelpersModuleNameText = "tslib"; + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; + if (declaration.kind === kind) { + return declaration; + } + } + } + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; + return { + string: function () { return str_1; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str_1 += " "; }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, + clear: function () { return str_1 = ""; }, + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function hasResolvedModule(sourceFile, moduleNameText) { + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = ts.createMap(); + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { + if (!sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + } + sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + } + ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; + function moduleResolutionIsEqualTo(oldResolution, newResolution) { + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; + } + ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function typeDirectiveIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + } + ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; + function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + if (names.length !== newResolutions.length) { + return false; + } + for (var i = 0; i < names.length; i++) { + var newResolution = newResolutions[i]; + var oldResolution = oldResolutions && oldResolutions[names[i]]; + var changed = oldResolution + ? !newResolution || !comparer(oldResolution, newResolution) + : newResolution; + if (changed) { + return true; + } + } + return false; + } + ts.hasChangesInResolutions = hasChangesInResolutions; + function containsParseError(node) { + aggregateChildData(node); + return (node.flags & 4194304) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.flags & 8388608)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.flags |= 4194304; + } + node.flags |= 8388608; + } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 261) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 204: + case 232: + case 211: + case 212: + case 213: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function isDefined(value) { + return value !== undefined; + } + ts.isDefined = isDefined; + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = ts.getLineStarts(sourceFile); + var lineIndex = line; + var sourceText = sourceFile.text; + if (lineIndex + 1 === lineStarts.length) { + return sourceText.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { + pos--; + } + return pos; + } + } + ts.getEndLinePosition = getEndLinePosition; + function nodeIsMissing(node) { + if (node === undefined) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { + if (nodeIsMissing(node)) { + return node.pos; + } + if (isJSDocNode(node)) { + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); + } + if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { + return getTokenPosOfNode(node.jsDocComments[0]); + } + if (node.kind === 291 && 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 >= 262 && node.kind <= 287; + } + ts.isJSDocNode = isJSDocNode; + function isJSDocTag(node) { + return node.kind >= 278 && node.kind <= 290; + } + ts.isJSDocTag = isJSDocTag; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function getLiteralText(node, sourceFile, languageVersion) { + if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + if (!nodeIsSynthesized(node) && node.parent) { + var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); + if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; + } + return text; + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 13: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + ts.getLiteralText = getLiteralText; + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; + } + } + return false; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + } + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || + isCatchClauseVariableDeclarationOrBindingElement(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 223 && node.parent.kind === 256; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; + function isAmbientModule(node) { + return node && node.kind === 230 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isShorthandAmbientModuleSymbol(moduleSymbol) { + return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + } + ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; + function isShorthandAmbientModule(node) { + return node.kind === 230 && (!node.body); + } + function isBlockScopedContainerTopLevel(node) { + return node.kind === 261 || + node.kind === 230 || + isFunctionLike(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 512); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; + } + switch (node.parent.kind) { + case 261: + return ts.isExternalModule(node.parent); + case 231: + return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isBlockScope(node, parentNode) { + switch (node.kind) { + case 261: + case 232: + case 256: + case 230: + case 211: + case 212: + case 213: + case 150: + case 149: + case 151: + case 152: + case 225: + case 184: + case 185: + return true; + case 204: + return parentNode && !isFunctionLike(parentNode); + } + return false; + } + ts.isBlockScope = isBlockScope; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isBlockScope(current, current.parent)) { + return current; + } + current = current.parent; + } + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function declarationNameToString(name) { + 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 177: + 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.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForArrowFunction(sourceFile, node) { + var pos = ts.skipTrivia(sourceFile.text, node.pos); + if (node.body && node.body.kind === 204) { + var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; + if (startLine < endLine) { + return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); + } + } + return ts.createTextSpanFromBounds(pos, node.end); + } + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 261: + 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 223: + case 174: + case 226: + case 197: + case 227: + case 230: + case 229: + case 260: + case 225: + case 184: + case 149: + case 151: + case 152: + case 228: + errorNode = node.name; + break; + case 185: + return getErrorSpanForArrowFunction(sourceFile, node); + } + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); + } + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; + function isDeclarationFile(file) { + return file.isDeclarationFile; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 229 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function isConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2) + || !!(ts.getCombinedModifierFlags(node) & 2048); + } + ts.isConst = isConst; + function isLet(node) { + return !!(ts.getCombinedNodeFlags(node) & 1); + } + ts.isLet = isLet; + function isSuperCall(n) { + return n.kind === 179 && n.expression.kind === 96; + } + ts.isSuperCall = isSuperCall; + function isPrologueDirective(node) { + return node.kind === 207 && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getLeadingCommentRangesOfNodeFromText(node, text) { + return ts.getLeadingCommentRanges(text, node.pos); + } + ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; + function getJsDocComments(node, sourceFileOfNode) { + return getJsDocCommentsFromText(node, sourceFileOfNode.text); + } + ts.getJsDocComments = getJsDocComments; + function getJsDocCommentsFromText(node, text) { + var commentRanges = (node.kind === 144 || + node.kind === 143 || + node.kind === 184 || + node.kind === 185) ? + ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : + getLeadingCommentRangesOfNodeFromText(node, text); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 42 && + text.charCodeAt(comment.pos + 3) !== 47; + } + } + ts.getJsDocCommentsFromText = getJsDocCommentsFromText; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isPartOfTypeNode(node) { + if (156 <= node.kind && node.kind <= 171) { + return true; + } + switch (node.kind) { + case 118: + case 132: + case 134: + case 121: + case 135: + case 137: + case 129: + return true; + case 104: + return node.parent.kind !== 188; + case 199: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 70: + if (node.parent.kind === 141 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 177 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 177, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141: + case 177: + case 98: + var parent_1 = node.parent; + if (parent_1.kind === 160) { + return false; + } + if (156 <= parent_1.kind && parent_1.kind <= 171) { + return true; + } + switch (parent_1.kind) { + case 199: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + case 143: + return node === parent_1.constraint; + case 147: + case 146: + case 144: + case 223: + return node === parent_1.type; + case 225: + case 184: + case 185: + case 150: + case 149: + case 148: + case 151: + case 152: + return node === parent_1.type; + case 153: + case 154: + case 155: + return node === parent_1.type; + case 182: + return node === parent_1.type; + case 179: + case 180: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 181: + return false; + } + } + return false; + } + ts.isPartOfTypeNode = isPartOfTypeNode; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 216: + return visitor(node); + case 232: + case 204: + case 208: + case 209: + case 210: + case 211: + case 212: + case 213: + case 217: + case 218: + case 253: + case 254: + case 219: + case 221: + case 256: + return ts.forEachChild(node, traverse); + } + } + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 195: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); + } + case 229: + case 227: + case 230: + case 228: + case 226: + case 197: + return; + default: + if (isFunctionLike(node)) { + var name_7 = node.name; + if (name_7 && name_7.kind === 142) { + traverse(name_7.expression); + return; + } + } + else if (!isPartOfTypeNode(node)) { + ts.forEachChild(node, traverse); + } + } + } + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 174: + case 260: + case 144: + case 257: + case 147: + case 146: + case 258: + case 223: + return true; + } + } + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 151 || node.kind === 152); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 226 || node.kind === 197); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + return node && isFunctionLikeKind(node.kind); + } + ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 150: + case 184: + case 225: + case 185: + case 149: + case 148: + case 151: + case 152: + case 153: + case 154: + case 155: + case 158: + case 159: + return true; + } + return false; + } + ts.isFunctionLikeKind = isFunctionLikeKind; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 149: + case 148: + case 150: + case 151: + case 152: + case 225: + case 184: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 211: + case 212: + case 213: + case 209: + case 210: + return true; + case 219: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 204 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 149 && node.parent.kind === 176; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 149 && + (node.parent.kind === 176 || + node.parent.kind === 197); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + function isIdentifierTypePredicate(predicate) { + return predicate && predicate.kind === 1; + } + ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; + } + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; + } + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 142: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + 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 185: + if (!includeArrowFunctions) { + continue; + } + case 225: + case 184: + case 230: + case 147: + case 146: + case 149: + case 148: + case 150: + case 151: + case 152: + case 153: + case 154: + case 155: + case 229: + case 261: + return node; + } + } + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, stopOnFunctions) { + while (true) { + node = node.parent; + if (!node) { + return node; + } + switch (node.kind) { + case 142: + node = node.parent; + break; + case 225: + case 184: + case 185: + if (!stopOnFunctions) { + continue; + } + case 147: + case 146: + case 149: + case 148: + case 150: + case 151: + case 152: + return node; + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + } + } + } + ts.getSuperContainer = getSuperContainer; + function getImmediatelyInvokedFunctionExpression(func) { + if (func.kind === 184 || func.kind === 185) { + var prev = func; + var parent_2 = func.parent; + while (parent_2.kind === 183) { + prev = parent_2; + parent_2 = parent_2.parent; + } + if (parent_2.kind === 179 && parent_2.expression === prev) { + return parent_2; + } + } + } + ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; + function isSuperProperty(node) { + var kind = node.kind; + return (kind === 177 || kind === 178) + && node.expression.kind === 96; + } + ts.isSuperProperty = isSuperProperty; + function getEntityNameFromTypeNode(node) { + switch (node.kind) { + case 157: + case 272: + return node.typeName; + case 199: + 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 179: + case 180: + case 181: + case 145: + return true; + default: + return false; + } + } + ts.isCallLikeExpression = isCallLikeExpression; + function getInvokedExpression(node) { + if (node.kind === 181) { + return node.tag; + } + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 226: + return true; + case 147: + return node.parent.kind === 226; + case 151: + case 152: + case 149: + return node.body !== undefined + && node.parent.kind === 226; + case 144: + return node.parent.body !== undefined + && (node.parent.kind === 150 + || node.parent.kind === 149 + || node.parent.kind === 152) + && node.parent.parent.kind === 226; + } + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + return node.decorators !== undefined + && nodeCanBeDecorated(node); + } + ts.nodeIsDecorated = nodeIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 226: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 149: + case 152: + return ts.forEach(node.parameters, nodeIsDecorated); + } + } + ts.childIsDecorated = childIsDecorated; + function isJSXTagName(node) { + var parent = node.parent; + if (parent.kind === 248 || + parent.kind === 247 || + parent.kind === 249) { + return parent.tagName === node; + } + return false; + } + ts.isJSXTagName = isJSXTagName; + function isPartOfExpression(node) { + switch (node.kind) { + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: + case 175: + case 176: + case 177: + case 178: + case 179: + case 180: + case 181: + case 200: + case 182: + case 201: + case 183: + case 184: + case 197: + case 185: + case 188: + case 186: + case 187: + case 190: + case 191: + case 192: + case 193: + case 196: + case 194: + case 12: + case 198: + case 246: + case 247: + case 195: + case 189: + return true; + case 141: + while (node.parent.kind === 141) { + node = node.parent; + } + return node.parent.kind === 160 || isJSXTagName(node); + case 70: + if (node.parent.kind === 160 || isJSXTagName(node)) { + return true; + } + case 8: + case 9: + case 98: + var parent_3 = node.parent; + switch (parent_3.kind) { + case 223: + case 144: + case 147: + case 146: + case 260: + case 257: + case 174: + return parent_3.initializer === node; + case 207: + case 208: + case 209: + case 210: + case 216: + case 217: + case 218: + case 253: + case 220: + case 218: + return parent_3.expression === node; + case 211: + var forStatement = parent_3; + return (forStatement.initializer === node && forStatement.initializer.kind !== 224) || + forStatement.condition === node || + forStatement.incrementor === node; + case 212: + case 213: + var forInStatement = parent_3; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224) || + forInStatement.expression === node; + case 182: + case 200: + return node === parent_3.expression; + case 202: + return node === parent_3.expression; + case 142: + return node === parent_3.expression; + case 145: + case 252: + case 251: + return true; + case 199: + return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + default: + if (isPartOfExpression(parent_3)) { + return true; + } + } + } + return false; + } + ts.isPartOfExpression = isPartOfExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 234 && node.moduleReference.kind === 245; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 234 && node.moduleReference.kind !== 245; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.flags & 2097152); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 179 && + expression.expression.kind === 70 && + expression.expression.text === "require" && + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + } + ts.isRequireCall = isRequireCall; + function isSingleOrDoubleQuote(charCode) { + return charCode === 39 || charCode === 34; + } + ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; + function isDeclarationOfFunctionExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 223) { + var declaration = s.valueDeclaration; + return declaration.initializer && declaration.initializer.kind === 184; + } + return false; + } + ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + function getSpecialPropertyAssignmentKind(expression) { + if (!isInJavaScriptFile(expression)) { + return 0; + } + if (expression.kind !== 192) { + return 0; + } + var expr = expression; + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 177) { + return 0; + } + var lhs = expr.left; + if (lhs.expression.kind === 70) { + var lhsId = lhs.expression; + if (lhsId.text === "exports") { + return 1; + } + else if (lhsId.text === "module" && lhs.name.text === "exports") { + return 2; + } + } + else if (lhs.expression.kind === 98) { + return 4; + } + else if (lhs.expression.kind === 177) { + var innerPropertyAccess = lhs.expression; + if (innerPropertyAccess.expression.kind === 70) { + var innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return 1; + } + if (innerPropertyAccess.name.text === "prototype") { + return 3; + } + } + } + return 0; + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getExternalModuleName(node) { + if (node.kind === 235) { + return node.moduleSpecifier; + } + if (node.kind === 234) { + var reference = node.moduleReference; + if (reference.kind === 245) { + return reference.expression; + } + } + if (node.kind === 241) { + return node.moduleSpecifier; + } + if (node.kind === 230 && node.name.kind === 9) { + return node.name; + } + } + ts.getExternalModuleName = getExternalModuleName; + function getNamespaceDeclarationNode(node) { + if (node.kind === 234) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237) { + return importClause.namedBindings; + } + } + ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; + function isDefaultImport(node) { + return node.kind === 235 + && node.importClause + && !!node.importClause.name; + } + ts.isDefaultImport = isDefaultImport; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 144: + case 149: + case 148: + case 258: + case 257: + case 147: + case 146: + return node.questionToken !== undefined; + } + } + return false; + } + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 274 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 276; + } + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; + } + var jsDocTags = getJSDocTags(node, checkParentVariableStatement); + if (!jsDocTags) { + return undefined; + } + for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { + var tag = jsDocTags_1[_i]; + if (tag.kind === kind) { + return tag; + } + } + } + function append(previous, additional) { + if (additional) { + if (!previous) { + previous = []; + } + for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { + var x = additional_1[_i]; + previous.push(x); + } + } + return previous; + } + function getJSDocComments(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); + } + ts.getJSDocComments = getJSDocComments; + function getJSDocTags(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { + var result = []; + for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { + var doc = docs_1[_i]; + if (doc.tags) { + result.push.apply(result, doc.tags); + } + } + return result; + }, function (tags) { return tags; }); + } + function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { + var result = undefined; + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && + (node.parent).initializer === node && + node.parent.parent.parent.kind === 205; + var isVariableOfVariableDeclarationStatement = isVariableLike(node) && + node.parent.parent.kind === 205; + 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 === 230 && + node.parent && node.parent.kind === 230) { + result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); + } + var parent_4 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && + parent_4.kind === 192 && + parent_4.operatorToken.kind === 57 && + parent_4.parent.kind === 207; + if (isSourceOfAssignmentExpressionStatement) { + result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); + } + var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 257; + if (isPropertyAssignmentExpression) { + result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === 144) { + var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); + if (paramTags) { + result = append(result, getTags(paramTags)); + } + } + } + if (isVariableLike(node) && node.initializer) { + result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); + } + if (node.jsDocComments) { + if (result) { + result = append(result, getDocs(node.jsDocComments)); + } + else { + return getDocs(node.jsDocComments); + } + } + return result; + } + function getJSDocParameterTag(param, checkParentVariableStatement) { + var func = param.parent; + var tags = getJSDocTags(func, checkParentVariableStatement); + if (!param.name) { + var i = func.parameters.indexOf(param); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 280; }); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; + } + } + else if (param.name.kind === 70) { + var name_8 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 280 && tag.parameterName.text === name_8; }); + if (paramTags) { + return paramTags; + } + } + else { + return undefined; + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 282, false); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 281, true); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 283, false); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 70) { + var parameterName = parameter.name.text; + var jsDocTags = getJSDocTags(parameter.parent, true); + if (!jsDocTags) { + return undefined; + } + for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { + var tag = jsDocTags_2[_i]; + if (tag.kind === 280) { + var parameterTag = tag; + if (parameterTag.parameterName.text === parameterName) { + return parameterTag; + } + } + } + } + return undefined; + } + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); + } + ts.hasRestParameter = hasRestParameter; + function hasDeclaredRestParameter(s) { + return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); + } + ts.hasDeclaredRestParameter = hasDeclaredRestParameter; + function isRestParameter(node) { + if (node && (node.flags & 2097152)) { + if (node.type && node.type.kind === 275) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 275; + } + } + return isDeclaredRestParam(node); + } + ts.isRestParameter = isRestParameter; + function isDeclaredRestParam(node) { + return node && node.dotDotDotToken !== undefined; + } + ts.isDeclaredRestParam = isDeclaredRestParam; + function getAssignmentTargetKind(node) { + var parent = node.parent; + while (true) { + switch (parent.kind) { + case 192: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 190: + case 191: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 212: + case 213: + return parent.initializer === node ? 1 : 0; + case 183: + case 175: + case 196: + node = parent; + break; + case 258: + if (parent.name !== node) { + return 0; + } + case 257: + node = parent.parent; + break; + default: + return 0; + } + parent = node.parent; + } + } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } + ts.isAssignmentTarget = isAssignmentTarget; + function isNodeDescendantOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendantOf = isNodeDescendantOf; + function isInAmbientContext(node) { + while (node) { + if (hasModifier(node, 2) || (node.kind === 261 && node.isDeclarationFile)) { + return true; + } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclarationName(name) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 239 || parent.kind === 243) { + if (parent.propertyName) { + return true; + } + } + if (isDeclaration(parent)) { + return parent.name === name; + } + return false; + } + ts.isDeclarationName = isDeclarationName; + function isLiteralComputedPropertyDeclarationName(node) { + return (node.kind === 9 || node.kind === 8) && + node.parent.kind === 142 && + isDeclaration(node.parent.parent); + } + ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 147: + case 146: + case 149: + case 148: + case 151: + case 152: + case 260: + case 257: + case 177: + return parent.name === node; + case 141: + if (parent.right === node) { + while (parent.kind === 141) { + parent = parent.parent; + } + return parent.kind === 160; + } + return false; + case 174: + case 239: + return parent.propertyName === node; + case 243: + return true; + } + return false; + } + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 234 || + node.kind === 233 || + node.kind === 236 && !!node.name || + node.kind === 237 || + node.kind === 239 || + node.kind === 243 || + node.kind === 240 && exportAssignmentIsAlias(node); + } + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function exportAssignmentIsAlias(node) { + return isEntityNameExpression(node.expression); + } + ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 107); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; + if (clause.token === kind) { + return clause; + } + } + } + return undefined; + } + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.test(comment)) { + if (isNoDefaultLibRegEx.test(comment)) { + return { + isNoDefaultLib: true + }; + } + else { + var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + if (refMatchResult || refLibResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: (refMatchResult || refLibResult)[3] + }, + isNoDefaultLib: false, + isTypeReferenceDirective: !!refLibResult + }; + } + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; + } + } + return undefined; + } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 71 <= token && token <= 140; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function isStringOrNumericLiteral(kind) { + return kind === 9 || kind === 8; + } + ts.isStringOrNumericLiteral = isStringOrNumericLiteral; + function hasDynamicName(declaration) { + return declaration.name && isDynamicName(declaration.name); + } + ts.hasDynamicName = hasDynamicName; + function isDynamicName(name) { + return name.kind === 142 && + !isStringOrNumericLiteral(name.expression.kind) && + !isWellKnownSymbolSyntactically(name.expression); + } + ts.isDynamicName = isDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { + return name.text; + } + if (name.kind === 142) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); + } + else if (nameExpression.kind === 9 || nameExpression.kind === 8) { + return nameExpression.text; + } + } + return undefined; + } + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 70 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; + function isModifierKind(token) { + switch (token) { + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: + case 113: + case 111: + case 112: + case 130: + case 114: + return true; + } + return false; + } + ts.isModifierKind = isModifierKind; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 144; + } + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 174) { + node = node.parent.parent; + } + return node; + } + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(node) { + var kind = node.kind; + return kind === 150 + || kind === 184 + || kind === 225 + || kind === 185 + || kind === 149 + || kind === 151 + || kind === 152 + || kind === 230 + || kind === 261; + } + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function nodeIsSynthesized(node) { + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); + } + ts.nodeIsSynthesized = nodeIsSynthesized; + function getOriginalNode(node, nodeTest) { + if (node) { + while (node.original !== undefined) { + node = node.original; + } + } + return !nodeTest || nodeTest(node) ? node : undefined; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function getOriginalSourceFiles(sourceFiles) { + var originalSourceFiles = []; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); + if (originalSourceFile) { + originalSourceFiles.push(originalSourceFile); + } + } + return originalSourceFiles; + } + ts.getOriginalSourceFiles = getOriginalSourceFiles; + function getOriginalNodeId(node) { + node = getOriginalNode(node); + return node ? ts.getNodeId(node) : 0; + } + ts.getOriginalNodeId = getOriginalNodeId; + function getExpressionAssociativity(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + return getOperatorAssociativity(expression.kind, operator, hasArguments); + } + ts.getExpressionAssociativity = getExpressionAssociativity; + function getOperatorAssociativity(kind, operator, hasArguments) { + switch (kind) { + case 180: + return hasArguments ? 0 : 1; + case 190: + case 187: + case 188: + case 186: + case 189: + case 193: + case 195: + return 1; + case 192: + switch (operator) { + case 39: + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 1; + } + } + return 0; + } + ts.getOperatorAssociativity = getOperatorAssociativity; + function getExpressionPrecedence(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 180 && expression.arguments !== undefined; + return getOperatorPrecedence(expression.kind, operator, hasArguments); + } + ts.getExpressionPrecedence = getExpressionPrecedence; + function getOperator(expression) { + if (expression.kind === 192) { + return expression.operatorToken.kind; + } + else if (expression.kind === 190 || expression.kind === 191) { + return expression.operator; + } + else { + return expression.kind; + } + } + ts.getOperator = getOperator; + function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { + switch (nodeKind) { + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: + case 8: + case 9: + case 175: + case 176: + case 184: + case 185: + case 197: + case 246: + case 247: + case 11: + case 12: + case 194: + case 183: + case 198: + return 19; + case 181: + case 177: + case 178: + return 18; + case 180: + return hasArguments ? 18 : 17; + case 179: + return 17; + case 191: + return 16; + case 190: + case 187: + case 188: + case 186: + case 189: + return 15; + case 192: + switch (operatorKind) { + case 50: + case 51: + return 15; + case 39: + case 38: + case 40: + case 41: + return 14; + case 36: + case 37: + return 13; + case 44: + case 45: + case 46: + return 12; + case 26: + case 29: + case 28: + case 30: + case 91: + case 92: + return 11; + case 31: + case 33: + case 32: + case 34: + return 10; + case 47: + return 9; + case 49: + return 8; + case 48: + return 7; + case 52: + return 6; + case 53: + return 5; + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 3; + case 25: + return 0; + default: + return -1; + } + case 193: + return 4; + case 195: + return 2; + case 196: + return 1; + default: + return -1; + } + } + ts.getOperatorPrecedence = getOperatorPrecedence; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = ts.createMap(); + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; + } + } + else { + diagnostics = nonFileDiagnostics; + } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; + } + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; + } + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; + } + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); + } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); + } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function sortAndDeduplicate() { + if (!diagnosticsModified) { + return; + } + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + } + } + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = ts.createMap({ + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }); + function escapeString(s) { + s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s; + return s; + function getReplacement(c) { + return escapedCharsMap[c] || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); + } + } + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; + } + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; + } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output; + var indent; + var lineStart; + var lineCount; + var linePos; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function reset() { + output = ""; + indent = 0; + lineStart = true; + lineCount = 0; + linePos = 0; + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(text, node) { + write(getTextOfNodeFromSourceText(text, node)); + } + reset(); + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + isAtStartOfLine: function () { return lineStart; }, + reset: reset + }; + } + ts.createTextWriter = createTextWriter; + function getResolvedExternalModuleName(host, file) { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getExternalModuleNameFromDeclaration(host, resolver, declaration) { + var file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; + } + return getResolvedExternalModuleName(host, file); + } + ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; + function getExternalModuleNameFromPath(host, fileName) { + var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; + var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); + return ts.removeFileExtension(relativePath); + } + ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + } + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + } + return emitOutputFilePathWithoutExtension + extension; + } + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getDeclarationEmitOutputFilePath(sourceFile, host) { + var options = host.getCompilerOptions(); + var outputDir = options.declarationDir || options.outDir; + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; + } + ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; + function getSourceFilesToEmit(host, targetSourceFile) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + var moduleKind = ts.getEmitModuleKind(options); + var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + var sourceFiles = getAllEmittableSourceFiles(); + return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); + } + else { + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; + return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); + } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } + } + ts.getSourceFilesToEmit = getSourceFilesToEmit; + function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { + return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + } + ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; + function isNonDeclarationFile(sourceFile) { + return !isDeclarationFile(sourceFile); + } + function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { + return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } + function isBundleEmitNonExternalModule(sourceFile) { + return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + } + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(sourceFiles); + } + else { + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + onSingleFileEmit(host, sourceFile); + } + } + } + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); + } + function onBundledEmit(sourceFiles) { + if (sourceFiles.length) { + var jsFilePath = options.outFile || options.out; + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + } + } + } + ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + function getSourceMapFilePath(jsFilePath, options) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(host); + } + else { + 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 (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { + onSingleFileEmit(host, sourceFile); + } + } + } + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: declarationFilePath + }; + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); + } + function onBundledEmit(host) { + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && + !host.isSourceFileFromExternalLibrary(sourceFile) && + (!ts.isExternalModule(sourceFile) || + !!ts.getEmitModuleKind(options)); }); + if (bundledSources.length) { + var jsFilePath = options.outFile || options.out; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined + }; + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + } + } + } + ts.forEachExpectedEmitFile = forEachExpectedEmitFile; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + var commonSourceDirectory = host.getCommonSourceDirectory(); + var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }, sourceFiles); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getLineOfLocalPositionFromLineMap(lineMap, pos) { + return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + } + ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 150 && nodeIsPresent(member.body)) { + return member; + } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + if (accessor && accessor.parameters.length > 0) { + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0].type; + } + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 70 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 98; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 151) { + getAccessor = accessor; + } + else if (accessor.kind === 152) { + setAccessor = accessor; + } + else { + ts.Debug.fail("Accessor has wrong kind"); + } + } + else { + ts.forEach(declarations, function (member) { + if ((member.kind === 151 || member.kind === 152) + && hasModifier(member, 32) === hasModifier(accessor, 32)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 151 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 152 && !setAccessor) { + setAccessor = member; + } + } + } + }); + } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { + emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { + if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { + if (pos !== commentPos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { + writer.writeLine(); + } + } + ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; + function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { + if (comments && comments.length > 0) { + if (leadingSeparator) { + writer.write(" "); + } + var emitInterveningSeparator = false; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + if (emitInterveningSeparator) { + writer.write(" "); + emitInterveningSeparator = false; + } + writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else { + emitInterveningSeparator = true; + } + } + if (emitInterveningSeparator && trailingSeparator) { + writer.write(" "); + } + } + } + ts.emitComments = emitComments; + function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment = void 0; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); + var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); + emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; + function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (text.charCodeAt(commentPos + 1) === 42) { + var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); + var lineCount = lineMap.length; + var firstCommentLineIndent = void 0; + for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? text.length + 1 + : lineMap[currentLine + 1]; + if (pos !== commentPos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(text.substring(commentPos, commentEnd)); + } + } + ts.writeCommentRange = writeCommentRange; + function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { + var end = Math.min(commentEnd, nextLineStart - 1); + var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== commentEnd) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(text, pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { + if (text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + function hasModifiers(node) { + return getModifierFlags(node) !== 0; + } + ts.hasModifiers = hasModifiers; + function hasModifier(node, flags) { + return (getModifierFlags(node) & flags) !== 0; + } + ts.hasModifier = hasModifier; + function getModifierFlags(node) { + if (node.modifierFlagsCache & 536870912) { + return node.modifierFlagsCache & ~536870912; + } + var flags = 0; + if (node.modifiers) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + flags |= modifierToFlag(modifier.kind); + } + } + if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + flags |= 1; + } + node.modifierFlagsCache = flags | 536870912; + return flags; + } + ts.getModifierFlags = getModifierFlags; + function modifierToFlag(token) { + switch (token) { + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 130: return 64; + } + return 0; + } + ts.modifierToFlag = modifierToFlag; + function isLogicalOperator(token) { + return token === 53 + || token === 52 + || token === 50; + } + ts.isLogicalOperator = isLogicalOperator; + function isAssignmentOperator(token) { + return token >= 57 && token <= 69; + } + ts.isAssignmentOperator = isAssignmentOperator; + function tryGetClassExtendingExpressionWithTypeArguments(node) { + if (node.kind === 199 && + 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 === 176 + || kind === 175; + } + } + return false; + } + ts.isDestructuringAssignment = isDestructuringAssignment; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 70) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + else { + return false; + } + } + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; + } + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isEntityNameExpression(node) { + return node.kind === 70 || + node.kind === 177 && isEntityNameExpression(node.expression); + } + ts.isEntityNameExpression = isEntityNameExpression; + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 141 && node.parent.right === node) || + (node.parent.kind === 177 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 176) { + return expression.properties.length === 0; + } + if (kind === 175) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; + } + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function tryExtractTypeScriptExtension(fileName) { + return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + } + ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); + } + else { + ts.Debug.assert(false, "Unexpected code point"); + } + } + return output; + } + ts.stringify = typeof JSON !== "undefined" && JSON.stringify + ? JSON.stringify + : stringifyFallback; + function stringifyFallback(value) { + return value === undefined ? undefined : stringifyValue(value); + } + function stringifyValue(value) { + return typeof value === "string" ? "\"" + escapeString(value) + "\"" + : typeof value === "number" ? isFinite(value) ? String(value) : "null" + : typeof value === "boolean" ? value ? "true" : "false" + : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) + : "null"; + } + function cycleCheck(cb, value) { + ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); + value.__cycle = true; + var result = cb(value); + delete value.__cycle; + return result; + } + function stringifyArray(value) { + return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; + } + function stringifyElement(memo, value) { + return (memo ? memo + "," : memo) + stringifyValue(value); + } + function stringifyObject(value) { + return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; + } + function stringifyProperty(memo, value, key) { + return value === undefined || typeof value === "function" || key === "__cycle" ? memo + : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); + } + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; + } + return result; + } + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; + } + else if (options.newLine === 1) { + return lineFeed; + } + else if (ts.sys) { + return ts.sys.newLine; + } + return carriageReturnLineFeed; + } + ts.getNewLineCharacter = getNewLineCharacter; + function isSimpleExpression(node) { + return isSimpleExpressionWorker(node, 0); + } + ts.isSimpleExpression = isSimpleExpression; + function isSimpleExpressionWorker(node, depth) { + if (depth <= 5) { + var kind = node.kind; + if (kind === 9 + || kind === 8 + || kind === 11 + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { + return true; + } + else if (kind === 177) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 178) { + return isSimpleExpressionWorker(node.expression, depth + 1) + && isSimpleExpressionWorker(node.argumentExpression, depth + 1); + } + else if (kind === 190 + || kind === 191) { + return isSimpleExpressionWorker(node.operand, depth + 1); + } + else if (kind === 192) { + return node.operatorToken.kind !== 39 + && isSimpleExpressionWorker(node.left, depth + 1) + && isSimpleExpressionWorker(node.right, depth + 1); + } + else if (kind === 193) { + return isSimpleExpressionWorker(node.condition, depth + 1) + && isSimpleExpressionWorker(node.whenTrue, depth + 1) + && isSimpleExpressionWorker(node.whenFalse, depth + 1); + } + else if (kind === 188 + || kind === 187 + || kind === 186) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 175) { + return node.elements.length === 0; + } + else if (kind === 176) { + return node.properties.length === 0; + } + else if (kind === 179) { + if (!isSimpleExpressionWorker(node.expression, depth + 1)) { + return false; + } + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + if (!isSimpleExpressionWorker(argument, depth + 1)) { + return false; + } + } + return true; + } + } + return false; + } + var syntaxKindCache = ts.createMap(); + function formatSyntaxKind(kind) { + var syntaxKindEnum = ts.SyntaxKind; + if (syntaxKindEnum) { + if (syntaxKindCache[kind]) { + return syntaxKindCache[kind]; + } + for (var name_9 in syntaxKindEnum) { + if (syntaxKindEnum[name_9] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + } + } + } + else { + return kind.toString(); + } + } + ts.formatSyntaxKind = formatSyntaxKind; + function movePos(pos, value) { + return ts.positionIsSynthesized(pos) ? -1 : pos + value; + } + ts.movePos = movePos; + function createRange(pos, end) { + return { pos: pos, end: end }; + } + ts.createRange = createRange; + function moveRangeEnd(range, end) { + return createRange(range.pos, end); + } + ts.moveRangeEnd = moveRangeEnd; + function moveRangePos(range, pos) { + return createRange(pos, range.end); + } + ts.moveRangePos = moveRangePos; + function moveRangePastDecorators(node) { + return node.decorators && node.decorators.length > 0 + ? moveRangePos(node, node.decorators.end) + : node; + } + ts.moveRangePastDecorators = moveRangePastDecorators; + function moveRangePastModifiers(node) { + return node.modifiers && node.modifiers.length > 0 + ? moveRangePos(node, node.modifiers.end) + : moveRangePastDecorators(node); + } + ts.moveRangePastModifiers = moveRangePastModifiers; + function isCollapsedRange(range) { + return range.pos === range.end; + } + ts.isCollapsedRange = isCollapsedRange; + function collapseRangeToStart(range) { + return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); + } + ts.collapseRangeToStart = collapseRangeToStart; + function collapseRangeToEnd(range) { + return isCollapsedRange(range) ? range : moveRangePos(range, range.end); + } + ts.collapseRangeToEnd = collapseRangeToEnd; + function createTokenRange(pos, token) { + return createRange(pos, pos + ts.tokenToString(token).length); + } + ts.createTokenRange = createTokenRange; + function rangeIsOnSingleLine(range, sourceFile) { + return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); + } + ts.rangeIsOnSingleLine = rangeIsOnSingleLine; + function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; + function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, range2.end, sourceFile); + } + ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; + function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); + } + ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; + function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); + } + ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function positionsAreOnSameLine(pos1, pos2, sourceFile) { + return pos1 === pos2 || + getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); + } + ts.positionsAreOnSameLine = positionsAreOnSameLine; + function getStartPositionOfRange(range, sourceFile) { + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + } + ts.getStartPositionOfRange = getStartPositionOfRange; + 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 235: + externalImports.push(node); + break; + case 234: + if (node.moduleReference.kind === 245) { + externalImports.push(node); + } + break; + case 241: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStarsToExportValues = true; + } + else { + externalImports.push(node); + } + } + else { + for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { + var specifier = _c[_b]; + 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 240: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + case 205: + 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 225: + 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 226: + 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; + } + } + 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 229: + case 230: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; + function getInitializedVariables(node) { + return ts.filter(node.declarations, isInitializedVariable); + } + ts.getInitializedVariables = getInitializedVariables; + function isInitializedVariable(node) { + return node.initializer !== undefined; + } + function isMergedWithClass(node) { + if (node.symbol) { + for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 226 && declaration !== node) { + return true; + } + } + } + return false; + } + ts.isMergedWithClass = isMergedWithClass; + function isFirstDeclarationOfKind(node, kind) { + return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; + } + ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; + function isNodeArray(array) { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); + } + ts.isNodeArray = isNodeArray; + function isNoSubstitutionTemplateLiteral(node) { + return node.kind === 12; + } + ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 12; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 12; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isLiteralExpression(node) { + return isLiteralKind(node.kind); + } + ts.isLiteralExpression = isLiteralExpression; + function isTemplateLiteralKind(kind) { + return 12 <= kind && kind <= 15; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateHead(node) { + return node.kind === 13; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 14 + || kind === 15; + } + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; + function isIdentifier(node) { + return node.kind === 70; + } + ts.isIdentifier = isIdentifier; + function isGeneratedIdentifier(node) { + return isIdentifier(node) && node.autoGenerateKind > 0; + } + ts.isGeneratedIdentifier = isGeneratedIdentifier; + function isModifier(node) { + return isModifierKind(node.kind); + } + ts.isModifier = isModifier; + function isQualifiedName(node) { + return node.kind === 141; + } + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 142; + } + ts.isComputedPropertyName = isComputedPropertyName; + function isEntityName(node) { + var kind = node.kind; + return kind === 141 + || kind === 70; + } + ts.isEntityName = isEntityName; + function isPropertyName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9 + || kind === 8 + || kind === 142; + } + ts.isPropertyName = isPropertyName; + function isModuleName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9; + } + ts.isModuleName = isModuleName; + function isBindingName(node) { + var kind = node.kind; + return kind === 70 + || kind === 172 + || kind === 173; + } + ts.isBindingName = isBindingName; + function isTypeParameter(node) { + return node.kind === 143; + } + ts.isTypeParameter = isTypeParameter; + function isParameter(node) { + return node.kind === 144; + } + ts.isParameter = isParameter; + function isDecorator(node) { + return node.kind === 145; + } + ts.isDecorator = isDecorator; + function isMethodDeclaration(node) { + return node.kind === 149; + } + ts.isMethodDeclaration = isMethodDeclaration; + function isClassElement(node) { + var kind = node.kind; + return kind === 150 + || kind === 147 + || kind === 149 + || kind === 151 + || kind === 152 + || kind === 155 + || kind === 203; + } + ts.isClassElement = isClassElement; + function isObjectLiteralElementLike(node) { + var kind = node.kind; + return kind === 257 + || kind === 258 + || kind === 259 + || kind === 149 + || kind === 151 + || kind === 152 + || kind === 244; + } + ts.isObjectLiteralElementLike = isObjectLiteralElementLike; + function isTypeNodeKind(kind) { + return (kind >= 156 && kind <= 171) + || kind === 118 + || kind === 132 + || kind === 121 + || kind === 134 + || kind === 135 + || kind === 104 + || kind === 129 + || kind === 199; + } + function isTypeNode(node) { + return isTypeNodeKind(node.kind); + } + ts.isTypeNode = isTypeNode; + function isBindingPattern(node) { + if (node) { + var kind = node.kind; + return kind === 173 + || kind === 172; + } + return false; + } + ts.isBindingPattern = isBindingPattern; + function isBindingElement(node) { + return node.kind === 174; + } + ts.isBindingElement = isBindingElement; + function isArrayBindingElement(node) { + var kind = node.kind; + return kind === 174 + || kind === 198; + } + ts.isArrayBindingElement = isArrayBindingElement; + function isArrayLiteralExpression(node) { + return node.kind === 175; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 176; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; + function isPropertyAccessExpression(node) { + return node.kind === 177; + } + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 178; + } + ts.isElementAccessExpression = isElementAccessExpression; + function isBinaryExpression(node) { + return node.kind === 192; + } + ts.isBinaryExpression = isBinaryExpression; + function isConditionalExpression(node) { + return node.kind === 193; + } + ts.isConditionalExpression = isConditionalExpression; + function isCallExpression(node) { + return node.kind === 179; + } + ts.isCallExpression = isCallExpression; + function isTemplateLiteral(node) { + var kind = node.kind; + return kind === 194 + || kind === 12; + } + ts.isTemplateLiteral = isTemplateLiteral; + function isSpreadExpression(node) { + return node.kind === 196; + } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 199; + } + ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; + function isLeftHandSideExpressionKind(kind) { + return kind === 177 + || kind === 178 + || kind === 180 + || kind === 179 + || kind === 246 + || kind === 247 + || kind === 181 + || kind === 175 + || kind === 183 + || kind === 176 + || kind === 197 + || kind === 184 + || kind === 70 + || kind === 11 + || kind === 8 + || kind === 9 + || kind === 12 + || kind === 194 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 201; + } + function isLeftHandSideExpression(node) { + return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isUnaryExpressionKind(kind) { + return kind === 190 + || kind === 191 + || kind === 186 + || kind === 187 + || kind === 188 + || kind === 189 + || kind === 182 + || isLeftHandSideExpressionKind(kind); + } + function isUnaryExpression(node) { + return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isUnaryExpression = isUnaryExpression; + function isExpressionKind(kind) { + return kind === 193 + || kind === 195 + || kind === 185 + || kind === 192 + || kind === 196 + || kind === 200 + || kind === 198 + || isUnaryExpressionKind(kind); + } + function isExpression(node) { + return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + } + ts.isExpression = isExpression; + function isAssertionExpression(node) { + var kind = node.kind; + return kind === 182 + || kind === 200; + } + ts.isAssertionExpression = isAssertionExpression; + function isPartiallyEmittedExpression(node) { + return node.kind === 293; + } + ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; + function isNotEmittedStatement(node) { + return node.kind === 292; + } + ts.isNotEmittedStatement = isNotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node) { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); + } + ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; + function isOmittedExpression(node) { + return node.kind === 198; + } + ts.isOmittedExpression = isOmittedExpression; + function isTemplateSpan(node) { + return node.kind === 202; + } + ts.isTemplateSpan = isTemplateSpan; + function isBlock(node) { + return node.kind === 204; + } + ts.isBlock = isBlock; + function isConciseBody(node) { + return isBlock(node) + || isExpression(node); + } + ts.isConciseBody = isConciseBody; + function isFunctionBody(node) { + return isBlock(node); + } + ts.isFunctionBody = isFunctionBody; + function isForInitializer(node) { + return isVariableDeclarationList(node) + || isExpression(node); + } + ts.isForInitializer = isForInitializer; + function isVariableDeclaration(node) { + return node.kind === 223; + } + ts.isVariableDeclaration = isVariableDeclaration; + function isVariableDeclarationList(node) { + return node.kind === 224; + } + ts.isVariableDeclarationList = isVariableDeclarationList; + function isCaseBlock(node) { + return node.kind === 232; + } + ts.isCaseBlock = isCaseBlock; + function isModuleBody(node) { + var kind = node.kind; + return kind === 231 + || kind === 230; + } + ts.isModuleBody = isModuleBody; + function isImportEqualsDeclaration(node) { + return node.kind === 234; + } + ts.isImportEqualsDeclaration = isImportEqualsDeclaration; + function isImportClause(node) { + return node.kind === 236; + } + ts.isImportClause = isImportClause; + function isNamedImportBindings(node) { + var kind = node.kind; + return kind === 238 + || kind === 237; + } + ts.isNamedImportBindings = isNamedImportBindings; + function isImportSpecifier(node) { + return node.kind === 239; + } + ts.isImportSpecifier = isImportSpecifier; + function isNamedExports(node) { + return node.kind === 242; + } + ts.isNamedExports = isNamedExports; + function isExportSpecifier(node) { + return node.kind === 243; + } + ts.isExportSpecifier = isExportSpecifier; + function isModuleOrEnumDeclaration(node) { + return node.kind === 230 || node.kind === 229; + } + ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; + function isDeclarationKind(kind) { + return kind === 185 + || kind === 174 + || kind === 226 + || kind === 197 + || kind === 150 + || kind === 229 + || kind === 260 + || kind === 243 + || kind === 225 + || kind === 184 + || kind === 151 + || kind === 236 + || kind === 234 + || kind === 239 + || kind === 227 + || kind === 149 + || kind === 148 + || kind === 230 + || kind === 233 + || kind === 237 + || kind === 144 + || kind === 257 + || kind === 147 + || kind === 146 + || kind === 152 + || kind === 258 + || kind === 228 + || kind === 143 + || kind === 223 + || kind === 284; + } + function isDeclarationStatementKind(kind) { + return kind === 225 + || kind === 244 + || kind === 226 + || kind === 227 + || kind === 228 + || kind === 229 + || kind === 230 + || kind === 235 + || kind === 234 + || kind === 241 + || kind === 240 + || kind === 233; + } + function isStatementKindButNotDeclarationKind(kind) { + return kind === 215 + || kind === 214 + || kind === 222 + || kind === 209 + || kind === 207 + || kind === 206 + || kind === 212 + || kind === 213 + || kind === 211 + || kind === 208 + || kind === 219 + || kind === 216 + || kind === 218 + || kind === 220 + || kind === 221 + || kind === 205 + || kind === 210 + || kind === 217 + || kind === 292 + || kind === 295 + || kind === 294; + } + function isDeclaration(node) { + return isDeclarationKind(node.kind); + } + ts.isDeclaration = isDeclaration; + function isDeclarationStatement(node) { + return isDeclarationStatementKind(node.kind); + } + ts.isDeclarationStatement = isDeclarationStatement; + function isStatementButNotDeclaration(node) { + return isStatementKindButNotDeclarationKind(node.kind); + } + ts.isStatementButNotDeclaration = isStatementButNotDeclaration; + function isStatement(node) { + var kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === 204; + } + ts.isStatement = isStatement; + function isModuleReference(node) { + var kind = node.kind; + return kind === 245 + || kind === 141 + || kind === 70; + } + ts.isModuleReference = isModuleReference; + function isJsxOpeningElement(node) { + return node.kind === 248; + } + ts.isJsxOpeningElement = isJsxOpeningElement; + function isJsxClosingElement(node) { + return node.kind === 249; + } + ts.isJsxClosingElement = isJsxClosingElement; + function isJsxTagNameExpression(node) { + var kind = node.kind; + return kind === 98 + || kind === 70 + || kind === 177; + } + ts.isJsxTagNameExpression = isJsxTagNameExpression; + function isJsxChild(node) { + var kind = node.kind; + return kind === 246 + || kind === 252 + || kind === 247 + || kind === 10; + } + ts.isJsxChild = isJsxChild; + function isJsxAttributeLike(node) { + var kind = node.kind; + return kind === 250 + || kind === 251; + } + ts.isJsxAttributeLike = isJsxAttributeLike; + function isJsxSpreadAttribute(node) { + return node.kind === 251; + } + ts.isJsxSpreadAttribute = isJsxSpreadAttribute; + function isJsxAttribute(node) { + return node.kind === 250; + } + ts.isJsxAttribute = isJsxAttribute; + function isStringLiteralOrJsxExpression(node) { + var kind = node.kind; + return kind === 9 + || kind === 252; + } + ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isCaseOrDefaultClause(node) { + var kind = node.kind; + return kind === 253 + || kind === 254; + } + ts.isCaseOrDefaultClause = isCaseOrDefaultClause; + function isHeritageClause(node) { + return node.kind === 255; + } + ts.isHeritageClause = isHeritageClause; + function isCatchClause(node) { + return node.kind === 256; + } + ts.isCatchClause = isCatchClause; + function isPropertyAssignment(node) { + return node.kind === 257; + } + ts.isPropertyAssignment = isPropertyAssignment; + function isShorthandPropertyAssignment(node) { + return node.kind === 258; + } + ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; + function isEnumMember(node) { + return node.kind === 260; + } + ts.isEnumMember = isEnumMember; + function isSourceFile(node) { + return node.kind === 261; + } + ts.isSourceFile = isSourceFile; + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); + } + ts.isWatchSet = isWatchSet; +})(ts || (ts = {})); +(function (ts) { + function getDefaultLibFileName(options) { + switch (options.target) { + case 5: + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } + } + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; + } + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; + } + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); + } + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + } + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; + } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); + } + return undefined; + } + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + } + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; + } + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; + } + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; + } + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); + } + return undefined; + } + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; + } + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); + } + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); + } + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; + } + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); + } + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; + } + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + } + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 143) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 227) { + return current; + } + } + } + } + ts.getTypeParameterOwner = getTypeParameterOwner; + function isParameterPropertyDeclaration(node) { + return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); + } + ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 174 || ts.isBindingPattern(node))) { + node = node.parent; + } + return node; + } + function getCombinedModifierFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = ts.getModifierFlags(node); + if (node.kind === 223) { + node = node.parent; + } + if (node && node.kind === 224) { + flags |= ts.getModifierFlags(node); + node = node.parent; + } + if (node && node.kind === 205) { + flags |= ts.getModifierFlags(node); + } + return flags; + } + ts.getCombinedModifierFlags = getCombinedModifierFlags; + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 223) { + node = node.parent; + } + if (node && node.kind === 224) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 205) { + flags |= node.flags; + } + return flags; + } + ts.getCombinedNodeFlags = getCombinedNodeFlags; +})(ts || (ts = {})); +var ts; (function (ts) { var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 + var ConstructorForKind = kind === 261 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -9781,7 +10777,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; } @@ -9793,12 +10789,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; @@ -9808,16 +10800,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; @@ -9835,7 +10827,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; @@ -9855,7 +10847,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; @@ -9873,7 +10865,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; @@ -9892,7 +10884,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; @@ -9910,7 +10902,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(172, location); node.elements = createNodeArray(elements); return node; } @@ -9923,7 +10915,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169, location); + var node = createNode(173, location); node.elements = createNodeArray(elements); return node; } @@ -9936,7 +10928,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170, location); + var node = createNode(174, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -9952,7 +10944,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171, location); + var node = createNode(175, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -9968,7 +10960,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172, location); + var node = createNode(176, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -9984,7 +10976,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173, location, flags); + var node = createNode(177, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10001,7 +10993,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174, location); + var node = createNode(178, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10015,7 +11007,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(179, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10032,7 +11024,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176, location, flags); + var node = createNode(180, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10047,7 +11039,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177, location); + var node = createNode(181, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10061,7 +11053,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179, location); + var node = createNode(183, location); node.expression = expression; return node; } @@ -10074,7 +11066,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(184, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10093,7 +11085,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(185, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10111,7 +11103,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182, location); + var node = createNode(186, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10124,7 +11116,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183, location); + var node = createNode(187, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10137,7 +11129,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184, location); + var node = createNode(188, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10150,7 +11142,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185, location); + var node = createNode(189, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10163,7 +11155,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186, location); + var node = createNode(190, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10177,7 +11169,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187, location); + var node = createNode(191, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10193,7 +11185,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(192, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10208,7 +11200,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189, location); + var node = createNode(193, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10225,7 +11217,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190, location); + var node = createNode(194, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10239,7 +11231,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191, location); + var node = createNode(195, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10253,7 +11245,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192, location); + var node = createNode(196, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10266,7 +11258,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193, location); + var node = createNode(197, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10284,12 +11276,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194, location); + var node = createNode(198, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195, location); + var node = createNode(199, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10303,7 +11295,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(198, location); + var node = createNode(202, location); node.expression = expression; node.literal = literal; return node; @@ -10317,7 +11309,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(200, location, flags); + var block = createNode(204, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10333,7 +11325,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201, location, flags); + var node = createNode(205, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10348,7 +11340,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(224, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10361,7 +11353,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(223, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10376,11 +11368,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202, location); + return createNode(206, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203, location, flags); + var node = createNode(207, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10393,7 +11385,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204, location); + var node = createNode(208, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -10408,7 +11400,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205, location); + var node = createNode(209, location); node.statement = statement; node.expression = expression; return node; @@ -10422,7 +11414,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206, location); + var node = createNode(210, location); node.expression = expression; node.statement = statement; return node; @@ -10436,7 +11428,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207, location, undefined); + var node = createNode(211, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -10452,7 +11444,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(212, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10467,7 +11459,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209, location); + var node = createNode(213, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10482,7 +11474,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210, location); + var node = createNode(214, location); if (label) { node.label = label; } @@ -10497,7 +11489,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211, location); + var node = createNode(215, location); if (label) { node.label = label; } @@ -10512,7 +11504,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -10525,7 +11517,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213, location); + var node = createNode(217, location); node.expression = expression; node.statement = statement; return node; @@ -10539,7 +11531,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214, location); + var node = createNode(218, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -10553,7 +11545,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215, location); + var node = createNode(219, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -10567,7 +11559,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216, location); + var node = createNode(220, location); node.expression = expression; return node; } @@ -10580,7 +11572,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217, location); + var node = createNode(221, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -10595,7 +11587,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228, location); + var node = createNode(232, location); node.clauses = createNodeArray(clauses); return node; } @@ -10608,7 +11600,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(225, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10628,7 +11620,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222, location); + var node = createNode(226, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10646,7 +11638,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231, location); + var node = createNode(235, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -10662,7 +11654,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232, location); + var node = createNode(236, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -10676,7 +11668,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233, location); + var node = createNode(237, location); node.name = name; return node; } @@ -10689,7 +11681,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -10702,7 +11694,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235, location); + var node = createNode(239, location); node.propertyName = propertyName; node.name = name; return node; @@ -10716,7 +11708,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236, location); + var node = createNode(240, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -10732,7 +11724,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237, location); + var node = createNode(241, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -10748,7 +11740,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238, location); + var node = createNode(242, location); node.elements = createNodeArray(elements); return node; } @@ -10761,7 +11753,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239, location); + var node = createNode(243, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -10775,7 +11767,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242, location); + var node = createNode(246, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -10790,7 +11782,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(247, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -10804,7 +11796,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244, location); + var node = createNode(248, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -10818,7 +11810,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); + var node = createNode(249, location); node.tagName = tagName; return node; } @@ -10831,7 +11823,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); + var node = createNode(250, location); node.name = name; node.initializer = initializer; return node; @@ -10845,7 +11837,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); + var node = createNode(251, location); node.expression = expression; return node; } @@ -10858,7 +11850,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248, location); + var node = createNode(252, location); node.expression = expression; return node; } @@ -10871,7 +11863,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(251, location); + var node = createNode(255, location); node.token = token; node.types = createNodeArray(types); return node; @@ -10885,7 +11877,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249, location); + var node = createNode(253, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -10899,7 +11891,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250, location); + var node = createNode(254, location); node.statements = createNodeArray(statements); return node; } @@ -10912,7 +11904,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); + var node = createNode(256, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -10926,7 +11918,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); + var node = createNode(257, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10941,12 +11933,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); + var node = createNode(258, 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(259, 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); @@ -10954,9 +11952,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(261, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11018,13 +12023,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(287, original); + var node = createNode(292, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + function createEndOfDeclarationMarker(original) { + var node = createNode(295); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + function createMergeDeclarationMarker(original) { + var node = createNode(294); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); + var node = createNode(293, location || original); node.expression = expression; node.original = original; return node; @@ -11096,10 +12115,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 @@ -11132,10 +12147,23 @@ var ts; function createReactNamespace(reactNamespace, parent) { var react = createIdentifier(reactNamespace || "React"); react.flags &= ~8; - react.parent = parent; + 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); @@ -11155,9 +12183,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); } @@ -11229,13 +12269,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([ @@ -11244,20 +12284,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 @@ -11283,13 +12323,13 @@ var ts; case 8: case 9: return false; - case 171: + case 175: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172: + case 176: return target.properties.length > 0; default: return true; @@ -11309,7 +12349,7 @@ var ts; } else { switch (callee.kind) { - case 173: { + case 177: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11320,7 +12360,7 @@ var ts; } break; } - case 174: { + case 178: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -11370,14 +12410,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 257: return createExpressionForPropertyAssignment(property, receiver); - case 254: + case 258: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148: + case 149: return createExpressionForMethodDeclaration(property, receiver); } } @@ -11418,6 +12458,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"; } @@ -11479,7 +12572,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 179) { + if (skipped.kind === 183) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -11488,15 +12581,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(192, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(192, 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 === 195) { return false; } return true; @@ -11535,7 +12628,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.kind === 192 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -11552,9 +12645,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175: + case 179: return createParen(expression); - case 176: + case 180: return emittedExpression.arguments ? expression : createParen(expression); @@ -11565,7 +12658,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && (emittedExpression.kind !== 180 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -11603,7 +12696,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(192, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -11614,7 +12707,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 || kind === 181) { + if (kind === 184 || kind === 185) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -11622,7 +12715,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + if (leftmostExpressionKind === 176 || leftmostExpressionKind === 184) { return createParen(expression, expression); } } @@ -11640,21 +12733,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187: + case 191: node = node.operand; continue; - case 188: + case 192: node = node.left; continue; - case 189: + case 193: node = node.condition; continue; - case 175: - case 174: - case 173: + case 179: + case 178: + case 177: node = node.expression; continue; - case 288: + case 293: node = node.expression; continue; } @@ -11663,19 +12756,12 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172) { + if (emittedBody.kind === 176) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; - (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; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -11695,7 +12781,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179) { + while (node.kind === 183) { node = node.expression; } return node; @@ -11709,7 +12795,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { + while (node.kind === 293) { node = node.expression; } return node; @@ -11765,7 +12851,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { + if (node.kind === 261) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -11855,13 +12941,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_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 === 235 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 && node.moduleSpecifier) { + if (node.kind === 241 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -11899,6 +12985,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 === 185); + 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 !== 185) { + 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) { @@ -11907,13 +13208,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256) { + if (kind === 261) { 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 { @@ -11949,26 +13250,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 258: 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 259: + return visitNode(cbNode, node.expression); + case 144: + case 147: case 146: - case 145: - case 253: - case 219: - case 170: + case 257: + case 223: + case 174: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -11977,24 +13280,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 184: + case 225: + case 185: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12005,308 +13308,318 @@ 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.readonlyToken) || + visitNode(cbNode, node.typeParameter) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type); case 171: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.literal); case 172: - return visitNodes(cbNodes, node.properties); case 173: + return visitNodes(cbNodes, node.elements); + case 175: + return visitNodes(cbNodes, node.elements); + case 176: + return visitNodes(cbNodes, node.properties); + case 177: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174: + case 178: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175: - case 176: + case 179: + case 180: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177: + case 181: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178: + case 182: 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 187: - return visitNode(cbNode, node.operand); + return visitNode(cbNode, node.expression); case 188: + return visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.operand); + case 195: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 189: + return visitNode(cbNode, node.expression); + case 191: + return visitNode(cbNode, node.operand); + case 192: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196: + case 200: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197: + case 201: return visitNode(cbNode, node.expression); - case 189: + case 193: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192: + case 196: return visitNode(cbNode, node.expression); - case 200: - case 227: + case 204: + case 231: return visitNodes(cbNodes, node.statements); - case 256: + case 261: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201: + case 205: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220: + case 224: return visitNodes(cbNodes, node.declarations); - case 203: + case 207: return visitNode(cbNode, node.expression); - case 204: + case 208: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205: + case 209: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207: + case 211: 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); case 212: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 213: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 228: - return visitNodes(cbNodes, node.clauses); - case 249: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 250: - return visitNodes(cbNodes, node.statements); case 215: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.label); case 216: return visitNode(cbNode, node.expression); case 217: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 218: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 232: + return visitNodes(cbNodes, node.clauses); + case 253: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 254: + return visitNodes(cbNodes, node.statements); + case 219: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 220: + return visitNode(cbNode, node.expression); + case 221: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252: + case 256: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144: + case 145: return visitNode(cbNode, node.expression); - case 222: - case 193: + case 226: + case 197: 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: + case 227: 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: + case 228: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 225: + case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255: + case 260: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 234: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231: + case 235: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229: - return visitNode(cbNode, node.name); case 233: return visitNode(cbNode, node.name); - case 234: - case 238: - return visitNodes(cbNodes, node.elements); case 237: + return visitNode(cbNode, node.name); + case 238: + case 242: + return visitNodes(cbNodes, node.elements); + case 241: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235: case 239: + case 243: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236: + case 240: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190: + case 194: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198: + case 202: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141: + case 142: return visitNode(cbNode, node.expression); - case 251: + case 255: return visitNodes(cbNodes, node.types); - case 195: + case 199: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241: + case 245: return visitNode(cbNode, node.expression); - case 240: + case 244: return visitNodes(cbNodes, node.decorators); - case 242: + case 246: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243: - case 244: + case 247: + case 248: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246: + case 250: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247: + case 251: return visitNode(cbNode, node.expression); - case 248: + case 252: return visitNode(cbNode, node.expression); - case 245: + case 249: 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); - case 268: - return visitNode(cbNode, node.type); - case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); - case 271: - return visitNode(cbNode, node.type); - case 272: return visitNode(cbNode, node.type); case 266: + return visitNodes(cbNodes, node.types); + case 267: + return visitNodes(cbNodes, node.types); + case 265: + return visitNode(cbNode, node.elementType); + case 269: + return visitNode(cbNode, node.type); + case 268: + return visitNode(cbNode, node.type); + case 270: + return visitNode(cbNode, node.literal); + case 272: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 273: + return visitNode(cbNode, node.type); + case 274: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.type); + case 276: + return visitNode(cbNode, node.type); + case 277: + return visitNode(cbNode, node.type); + case 271: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273: + case 278: return visitNodes(cbNodes, node.tags); - case 275: + case 280: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276: + case 281: return visitNode(cbNode, node.typeExpression); - case 277: + case 282: return visitNode(cbNode, node.typeExpression); - case 278: + case 283: return visitNodes(cbNodes, node.typeParameters); - case 279: + case 284: return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281: + case 286: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: + case 285: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288: + case 293: return visitNode(cbNode, node.expression); - case 282: + case 287: return visitNode(cbNode, node.literal); } } @@ -12320,6 +13633,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; } @@ -12342,8 +13659,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; @@ -12367,6 +13684,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; } @@ -12382,7 +13708,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); @@ -12457,7 +13783,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(261, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -12477,17 +13803,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) { @@ -12509,41 +13835,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; @@ -12684,7 +14010,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); } @@ -12704,7 +14030,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288; + node.flags |= 1048576; } return node; } @@ -12766,7 +14092,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); @@ -12836,9 +14162,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); @@ -12853,29 +14181,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'."); @@ -12919,7 +14247,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; @@ -12927,31 +14255,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; } } @@ -12968,7 +14297,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; @@ -13019,7 +14348,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 1540096; + var nodeContextFlags = node.flags & 3080192; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -13051,10 +14380,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: @@ -13066,14 +14397,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 203: return true; - case 148: + case 149: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -13085,8 +14416,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249: - case 250: + case 253: + case 254: return true; } } @@ -13095,65 +14426,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221: - case 201: - case 200: + case 225: + case 205: case 204: - case 203: + case 208: + case 207: + case 220: case 216: - case 212: + case 218: + case 215: case 214: + case 212: + case 213: case 211: case 210: - case 208: - case 209: - case 207: - case 206: - case 213: - case 202: case 217: - case 215: - case 205: - case 218: - case 231: - case 230: - case 237: - case 236: - case 226: + case 206: + case 221: + case 219: + case 209: case 222: - case 223: - case 225: - case 224: + case 235: + case 234: + case 241: + case 240: + case 230: + case 226: + case 227: + case 229: + case 228: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255; + return node.kind === 260; } 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 !== 223) { 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; @@ -13173,6 +14504,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; @@ -13184,17 +14516,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; } } ; @@ -13248,7 +14580,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); @@ -13265,7 +14597,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190); + var template = createNode(194); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -13277,7 +14609,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198); + var span = createNode(202); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -13325,33 +14657,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()) { @@ -13365,7 +14697,7 @@ var ts; } function parseTypeParameters() { if (token() === 26) { - return parseBracketedList(17, parseTypeParameter, 26, 28); + return parseBracketedList(18, parseTypeParameter, 26, 28); } } function parseParameterType() { @@ -13378,7 +14710,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(); @@ -13438,7 +14770,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -13478,7 +14810,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); @@ -13490,7 +14822,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; @@ -13499,7 +14831,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; @@ -13539,10 +14871,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(); @@ -13556,7 +14888,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(160); + var node = createNode(161); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -13571,13 +14903,40 @@ var ts; } return members; } + function isStartOfMappedType() { + nextToken(); + if (token() === 130) { + nextToken(); + } + return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; + } + function parseMappedTypeParameter() { + var node = createNode(143); + node.name = parseIdentifier(); + parseExpected(91); + node.constraint = parseType(); + return finishNode(node); + } + function parseMappedType() { + var node = createNode(170); + parseExpected(16); + node.readonlyToken = parseOptionalToken(130); + parseExpected(20); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(21); + node.questionToken = parseOptionalToken(54); + node.type = parseTypeAnnotation(); + parseSemicolon(); + parseExpected(17); + return finishNode(node); + } 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); @@ -13585,7 +14944,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -13596,7 +14955,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167); + var node = createNode(171); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -13607,12 +14966,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: @@ -13637,7 +14996,7 @@ var ts; case 102: return parseTypeQuery(); case 16: - return parseTypeLiteral(); + return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); case 20: return parseTupleType(); case 18: @@ -13649,16 +15008,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: @@ -13683,13 +15042,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) { @@ -13705,10 +15087,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) { @@ -13754,7 +15136,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); @@ -13771,14 +15153,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(); } @@ -13897,7 +15279,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191); + var node = createNode(195); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -13913,13 +15295,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(185, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181, identifier.pos); + node = createNode(185, 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); @@ -14053,7 +15435,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181); + var node = createNode(185); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -14085,7 +15467,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(189, leftOperand.pos); + var node = createNode(193, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14098,7 +15480,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) { @@ -14176,39 +15558,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188, left.pos); + var node = createNode(192, 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(200, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186); + var node = createNode(190); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182); + var node = createNode(186); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183); + var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184); + var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14223,7 +15605,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185); + var node = createNode(189); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14239,7 +15621,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178) { + if (simpleUnaryExpression.kind === 182) { 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 { @@ -14292,7 +15674,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(186); + var node = createNode(190); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14304,7 +15686,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(191, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14327,7 +15709,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(173, expression.pos); + var node = createNode(177, 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); @@ -14349,8 +15731,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 === 248) { + var node = createNode(246, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14360,14 +15742,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243); + ts.Debug.assert(opening.kind === 247); 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(192, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -14420,7 +15802,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(244, fullStart); + node = createNode(248, fullStart); scanJsxText(); } else { @@ -14432,7 +15814,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(243, fullStart); + node = createNode(247, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14443,7 +15825,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(177, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14451,7 +15833,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248); + var node = createNode(252); parseExpected(16); if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); @@ -14470,7 +15852,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246); + var node = createNode(250); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -14485,7 +15867,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247); + var node = createNode(251); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -14493,7 +15875,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245); + var node = createNode(249); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -14506,7 +15888,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178); + var node = createNode(182); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -14517,7 +15899,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(177, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14525,13 +15907,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197, expression.pos); + var nonNullExpression = createNode(201, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(174, expression.pos); + var indexedAccess = createNode(178, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -14545,7 +15927,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(177, expression.pos); + var tagExpression = createNode(181, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -14564,7 +15946,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(179, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -14572,7 +15954,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(179, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14591,7 +15973,7 @@ var ts; if (!parseOptional(26)) { return undefined; } - var typeArguments = parseDelimitedList(18, parseType); + var typeArguments = parseDelimitedList(19, parseType); if (!parseExpected(28)) { return undefined; } @@ -14667,28 +16049,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179); + var node = createNode(183); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192); + var node = createNode(196); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(194) : + token() === 25 ? createNode(198) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171); + var node = createNode(175); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14699,15 +16081,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(259, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -14723,7 +16111,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254, fullStart); + var shorthandDeclaration = createNode(258, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -14734,7 +16122,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253, fullStart); + var propertyAssignment = createNode(257, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -14744,7 +16132,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172); + var node = createNode(176); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14758,7 +16146,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(180); + var node = createNode(184); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -14780,7 +16168,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176); + var node = createNode(180); parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -14790,7 +16178,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200); + var node = createNode(204); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14821,12 +16209,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202); + var node = createNode(206); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(204); + var node = createNode(208); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14836,7 +16224,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205); + var node = createNode(209); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -14847,7 +16235,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206); + var node = createNode(210); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14870,21 +16258,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(208, pos); + var forInStatement = createNode(212, 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(213, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207, pos); + var forStatement = createNode(211, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -14902,7 +16290,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 ? 71 : 76); + parseExpected(kind === 215 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14910,7 +16298,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212); + var node = createNode(216); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -14919,7 +16307,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213); + var node = createNode(217); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -14928,7 +16316,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249); + var node = createNode(253); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -14936,7 +16324,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250); + var node = createNode(254); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -14946,12 +16334,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214); + var node = createNode(218); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(228, scanner.getStartPos()); + var caseBlock = createNode(232, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -14959,14 +16347,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(216); + var node = createNode(220); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(217); + var node = createNode(221); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -14977,7 +16365,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252); + var result = createNode(256); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -14987,7 +16375,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218); + var node = createNode(222); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -14996,13 +16384,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(219, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203, fullStart); + var expressionStatement = createNode(207, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15031,10 +16419,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: @@ -15042,13 +16430,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: @@ -15106,16 +16494,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(); @@ -15154,9 +16542,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(210); + return parseBreakOrContinueStatement(214); case 71: - return parseBreakOrContinueStatement(211); + return parseBreakOrContinueStatement(215); case 95: return parseReturnStatement(); case 106: @@ -15175,9 +16563,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: @@ -15188,8 +16576,8 @@ var ts; case 113: case 116: case 114: - case 129: - case 138: + case 130: + case 139: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15212,13 +16600,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); @@ -15235,7 +16623,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(244, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15256,16 +16644,17 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(194); + return createNode(198); } - var node = createNode(170); + var node = createNode(174); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170); + var node = createNode(174); + node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55) { @@ -15280,14 +16669,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168); + var node = createNode(172); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169); + var node = createNode(173); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -15306,7 +16695,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219); + var node = createNode(223); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15315,7 +16704,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220); + var node = createNode(224); switch (token()) { case 103: break; @@ -15329,7 +16718,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15344,7 +16733,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(205, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15352,7 +16741,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -15365,7 +16754,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); @@ -15374,7 +16763,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; @@ -15387,7 +16776,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; @@ -15395,7 +16784,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)); } @@ -15428,7 +16817,7 @@ var ts; case 111: case 112: case 114: - case 129: + case 130: return true; default: return false; @@ -15457,7 +16846,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()) { @@ -15480,7 +16869,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) { @@ -15537,7 +16926,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(199); + var result = createNode(203); nextToken(); return finishNode(result); } @@ -15562,16 +16951,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_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, 197); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -15600,13 +16989,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(255); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -15615,10 +17004,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195); + var node = createNode(199); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } @@ -15629,7 +17018,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -15640,10 +17029,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135); + parseExpected(136); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -15652,13 +17041,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(255, scanner.getStartPos()); + var node = createNode(260, 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(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -15673,7 +17062,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(231, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -15684,7 +17073,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226, fullStart); + var node = createNode(230, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -15696,10 +17085,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138) { + if (token() === 139) { node.name = parseIdentifier(); node.flags |= 512; } @@ -15716,14 +17105,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); } @@ -15731,7 +17120,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 && + return token() === 131 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -15741,13 +17130,13 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229, fullStart); + var exportDeclaration = createNode(233, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); - parseExpected(127); + parseExpected(128); exportDeclaration.name = parseIdentifier(); - parseExpected(24); + parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { @@ -15756,8 +17145,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(234, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -15767,27 +17156,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(231, fullStart); + var importDeclaration = createNode(235, 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(236, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(238); } return finishNode(importClause); } @@ -15797,8 +17186,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(241); - parseExpected(130); + var node = createNode(245); + parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); parseExpected(19); @@ -15815,7 +17204,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(233); + var namespaceImport = createNode(237); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -15823,14 +17212,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 === 238 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(243); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235); + return parseImportOrExportSpecifier(239); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15849,23 +17238,23 @@ var ts; else { node.name = identifierName; } - if (kind === 235 && checkIdentifierIsKeyword) { + if (kind === 239 && 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(241, 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(242); + if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -15873,7 +17262,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(240, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -15952,50 +17341,14 @@ 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 === 234 && node.moduleReference.kind === 245 + || node.kind === 235 + || node.kind === 240 + || node.kind === 241 ? node : undefined; }); } - var ParsingContext; - (function (ParsingContext) { - ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; - ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; - ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; - ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; - ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; - 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"; - })(ParsingContext || (ParsingContext = {})); - var Tristate; - (function (Tristate) { - Tristate[Tristate["False"] = 0] = "False"; - Tristate[Tristate["True"] = 1] = "True"; - Tristate[Tristate["Unknown"] = 2] = "Unknown"; - })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { @@ -16016,8 +17369,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(); @@ -16027,7 +17380,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(257, scanner.getTokenPos()); + var result = createNode(262, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -16038,12 +17391,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(261, type.pos); + var unionType = createNode(266, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(268, type.pos); + var optionalType = createNode(273, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -16054,20 +17407,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(260, type.pos); + var arrayType = createNode(265, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(263, type.pos); + var nullableType = createNode(268, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(264, type.pos); + var nonNullableType = createNode(269, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -16101,14 +17454,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: @@ -16119,30 +17472,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272); + var result = createNode(277); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271); + var result = createNode(276); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270); + var result = createNode(275); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269); + var result = createNode(274); nextToken(); parseExpected(18); - result.parameters = parseDelimitedList(22, parseJSDocParameter); + result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19); if (token() === 55) { @@ -16152,7 +17505,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); @@ -16160,7 +17513,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267); + var result = createNode(272); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -16180,7 +17533,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(23, parseJSDocType); + var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28); @@ -16194,26 +17547,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(270); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264); + var result = createNode(269); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262); + var result = createNode(267); nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); + result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21); return finishNode(result); @@ -16225,7 +17578,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261); + var result = createNode(266); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -16241,12 +17594,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258); + var result = createNode(263); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282); + var result = createNode(287); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -16259,17 +17612,17 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(259, pos); + var result = createNode(264, pos); return finishNode(result); } else { - var result = createNode(263, pos); + var result = createNode(268, 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; @@ -16291,12 +17644,6 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; - var JSDocState; - (function (JSDocState) { - JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; - JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; - JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; - })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -16329,6 +17676,7 @@ var ts; } if (token() === 4) { state = 0; + indent = 0; nextJSDocToken(); } while (token() !== 1) { @@ -16408,7 +17756,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(273, start); + var result = createNode(278, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16515,7 +17863,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274, atToken.pos); + var result = createNode(279, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16570,7 +17918,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -16581,20 +17929,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 === 281; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276, atToken.pos); + var result = createNode(281, 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 === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -16609,7 +17957,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -16619,18 +17967,25 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279, atToken.pos); + var typedefTag = createNode(284, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; - typedefTag.name = parseJSDocIdentifierName(); + typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); + if (typedefTag.fullName) { + var rightNode = typedefTag.fullName; + while (rightNode.kind !== 70) { + rightNode = rightNode.body; + } + typedefTag.name = rightNode; + } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267) { + if (typeExpression.type.kind === 272) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_11 = jsDocTypeReference.name; - if (name_11.text === "Object") { + var name_17 = jsDocTypeReference.name; + if (name_17.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -16644,7 +17999,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(286, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16681,6 +18036,21 @@ var ts; scanner.setTextPos(resumePos); return finishNode(jsDocTypeLiteral); } + function parseJSDocTypeNameWithNamespace(flags) { + var pos = scanner.getTokenPos(); + var typeNameOrNamespaceName = parseJSDocIdentifierName(); + if (typeNameOrNamespaceName && parseOptional(22)) { + var jsDocNamespaceNode = createNode(230, pos); + jsDocNamespaceNode.flags |= flags; + jsDocNamespaceNode.name = typeNameOrNamespaceName; + jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); + return jsDocNamespaceNode; + } + if (typeNameOrNamespaceName && flags & 4) { + typeNameOrNamespaceName.isInJSDocNamespace = true; + } + return typeNameOrNamespaceName; + } } function tryParseChildTag(parentTag) { ts.Debug.assert(token() === 56); @@ -16701,29 +18071,32 @@ var ts; return true; case "prop": case "property": - if (!parentTag.jsDocPropertyTags) { - parentTag.jsDocPropertyTags = []; - } var propertyTag = parsePropertyTag(atToken, tagName); - parentTag.jsDocPropertyTags.push(propertyTag); - return true; + if (propertyTag) { + if (!parentTag.jsDocPropertyTags) { + parentTag.jsDocPropertyTags = []; + } + parentTag.jsDocPropertyTags.push(propertyTag); + return true; + } + return false; } 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 === 283; })) { 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_18 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_12) { + if (!name_18) { 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_18.pos); + typeParameter.name = name_18; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -16734,7 +18107,7 @@ var ts; break; } } - var result = createNode(278, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -17048,31 +18421,21 @@ var ts; } } } - var InvalidPosition; - (function (InvalidPosition) { - InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; - })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { - (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; function getModuleInstanceState(node) { - if (node.kind === 223 || node.kind === 224) { + if (node.kind === 227 || node.kind === 228) { 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 === 235 || node.kind === 234) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 227) { + else if (node.kind === 231) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17088,27 +18451,18 @@ var ts; }); return state_1; } - else if (node.kind === 226) { + else if (node.kind === 230) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } + else if (node.kind === 70 && node.isInJSDocNamespace) { + return 0; + } else { return 1; } } ts.getModuleInstanceState = getModuleInstanceState; - var ContainerFlags; - (function (ContainerFlags) { - ContainerFlags[ContainerFlags["None"] = 0] = "None"; - ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; - ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; - ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; - ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; - ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; - ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; - ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; - ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; - })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -17206,7 +18560,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 === 230)) { symbol.valueDeclaration = node; } } @@ -17216,7 +18570,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; @@ -17227,21 +18581,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 241: return "__export"; - case 236: + case 240: return node.isExportEquals ? "export=" : "default"; - case 188: + case 192: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17253,20 +18607,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221: - case 222: + case 225: + case 226: return ts.hasModifier(node, 512) ? "default" : undefined; - case 269: + case 274: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143: - ts.Debug.assert(node.parent.kind === 269); + case 144: + ts.Debug.assert(node.parent.kind === 274); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279: + case 284: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 205) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -17310,7 +18664,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 240 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17330,7 +18684,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 === 243 || (node.kind === 234 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17338,7 +18692,11 @@ var ts; } } else { - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) { + var isJSDocTypedefInJSDocNamespace = node.kind === 284 && + node.name && + node.name.kind === 70 && + node.name.isInJSDocNamespace; + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793064 ? 2097152 : 0) | (symbolFlags & 1920 ? 4194304 : 0); @@ -17373,7 +18731,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(); } @@ -17389,13 +18747,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 === 261) { node.flags |= emitFlags; } if (isIIFE) { @@ -17430,6 +18788,7 @@ var ts; skipTransformFlagAggregation = true; bindChildrenWorker(node); skipTransformFlagAggregation = false; + subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); } else { var savedSubtreeTransformFlags = subtreeTransformFlags; @@ -17447,64 +18806,64 @@ var ts; return; } switch (node.kind) { - case 206: + case 210: bindWhileStatement(node); break; - case 205: + case 209: bindDoStatement(node); break; - case 207: + case 211: bindForStatement(node); break; - case 208: - case 209: + case 212: + case 213: bindForInOrForOfStatement(node); break; - case 204: + case 208: bindIfStatement(node); break; - case 212: case 216: + case 220: bindReturnOrThrow(node); break; - case 211: - case 210: + case 215: + case 214: bindBreakOrContinueStatement(node); break; - case 217: + case 221: bindTryStatement(node); break; - case 214: + case 218: bindSwitchStatement(node); break; - case 228: + case 232: bindCaseBlock(node); break; - case 249: + case 253: bindCaseClause(node); break; - case 215: + case 219: bindLabeledStatement(node); break; - case 186: + case 190: bindPrefixUnaryExpressionFlow(node); break; - case 187: + case 191: bindPostfixUnaryExpressionFlow(node); break; - case 188: + case 192: bindBinaryExpressionFlow(node); break; - case 182: + case 186: bindDeleteExpressionFlow(node); break; - case 189: + case 193: bindConditionalExpressionFlow(node); break; - case 219: + case 223: bindVariableDeclarationFlow(node); break; - case 175: + case 179: bindCallExpressionFlow(node); break; default: @@ -17516,15 +18875,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 177: return isNarrowableReference(expr); - case 175: - return hasNarrowableArgument(expr); case 179: + return hasNarrowableArgument(expr); + case 183: return isNarrowingExpression(expr.expression); - case 188: + case 192: return isNarrowingBinaryExpression(expr); - case 186: + case 190: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -17532,7 +18891,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 173 && isNarrowableReference(expr.expression); + expr.kind === 177 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17543,14 +18902,14 @@ var ts; } } } - if (expr.expression.kind === 173 && + if (expr.expression.kind === 177 && 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 === 187 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -17571,9 +18930,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179: + case 183: return isNarrowableOperand(expr.expression); - case 188: + case 192: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -17667,33 +19026,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204: - case 206: - case 205: + case 208: + case 210: + case 209: return parent.expression === node; - case 207: - case 189: + case 211: + case 193: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179) { + if (node.kind === 183) { node = node.expression; } - else if (node.kind === 186 && node.operator === 50) { + else if (node.kind === 190 && node.operator === 50) { node = node.operand; } else { - return node.kind === 188 && (node.operatorToken.kind === 52 || + return node.kind === 192 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 || - node.parent.kind === 186 && + while (node.parent.kind === 183 || + node.parent.kind === 190 && node.parent.operator === 50) { node = node.parent; } @@ -17735,8 +19094,11 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 219 + ? 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); @@ -17767,7 +19129,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220) { + if (node.initializer.kind !== 224) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17789,7 +19151,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212) { + if (node.kind === 216) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17809,7 +19171,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 ? breakTarget : continueTarget; + var flowLabel = node.kind === 215 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17866,7 +19228,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 === 254; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17927,11 +19289,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 !== 209) { + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 && node.operatorToken.kind === 57) { + if (node.kind === 192 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -17942,10 +19306,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171) { + else if (node.kind === 175) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192) { + if (e.kind === 196) { bindAssignmentTargetFlow(e.expression); } else { @@ -17953,15 +19317,18 @@ var ts; } } } - else if (node.kind === 172) { + else if (node.kind === 176) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253) { + if (p.kind === 257) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254) { + else if (p.kind === 258) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 259) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -18013,9 +19380,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 === 178) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18026,7 +19393,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173) { + if (node.expression.kind === 177) { bindAssignmentTargetFlow(node.expression); } } @@ -18036,9 +19403,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); @@ -18057,16 +19426,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 === 212 || node.parent.parent.kind === 213) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 179) { + while (expr.kind === 183) { expr = expr.expression; } - if (expr.kind === 180 || expr.kind === 181) { + if (expr.kind === 184 || expr.kind === 185) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18074,7 +19443,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173) { + if (node.expression.kind === 177) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18083,51 +19452,52 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193: - case 222: - case 225: - case 172: - case 160: - case 281: - case 265: - return 1; - case 223: - return 1 | 64; - case 269: + case 197: case 226: - case 224: + case 229: + case 176: + case 161: + case 286: + case 270: + return 1; + case 227: + return 1 | 64; + case 274: + case 230: + case 228: + case 170: return 1 | 32; - case 256: + case 261: 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 225: + 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 184: + case 185: return 1 | 4 | 32 | 8 | 16; - case 227: + case 231: return 4; - case 146: + case 147: return node.initializer ? 4 : 0; - case 252: - case 207: - case 208: - case 209: - case 228: + case 256: + case 211: + case 212: + case 213: + case 232: return 2; - case 200: + case 204: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18143,36 +19513,37 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 226: + case 230: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256: + case 261: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193: - case 222: + case 197: + case 226: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225: + case 229: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160: - case 172: - case 223: - case 265: - case 281: + case 161: + case 176: + case 227: + case 270: + case 286: 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 224: + case 152: + case 225: + case 184: + case 185: + case 274: + case 228: + case 170: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18187,11 +19558,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 === 261 ? node : node.body; + if (body && (body.kind === 261 || body.kind === 231)) { 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 === 241 || stat.kind === 240) { return true; } } @@ -18263,20 +19634,15 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); if (inStrictMode) { 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 === 259 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 + var currentKind = prop.kind === 257 || prop.kind === 258 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18298,10 +19664,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226: + case 230: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256: + case 261: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -18391,8 +19757,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 226 && + if (blockScopeContainer.kind !== 261 && + blockScopeContainer.kind !== 230 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18435,7 +19801,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); @@ -18473,17 +19839,25 @@ var ts; function bindWorker(node) { switch (node.kind) { case 70: + if (node.isInJSDocNamespace) { + var parentNode = node.parent; + while (parentNode && parentNode.kind !== 284) { + 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 === 258)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173: + case 177: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188: + case 192: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -18506,111 +19880,132 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252: + case 256: return checkStrictModeCatchClause(node); - case 182: + case 186: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 187: + case 191: return checkStrictModePostfixUnaryExpression(node); - case 186: + case 190: return checkStrictModePrefixUnaryExpression(node); - case 213: + case 217: 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 223: + case 174: + if (node.dotDotDotToken && node.parent.kind === 172) { + emitFlags |= 32768; + } return bindVariableDeclarationOrBindingElement(node); + case 147: case 146: - case 145: - case 266: + case 271: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 280: + case 285: return bindJSDocProperty(node); - case 253: - case 254: + case 257: + case 258: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 255: + case 260: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 247: - emitFlags |= 16384; + case 259: + case 251: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 176 && + root.parent.kind === 192 && + 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 225: + 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 274: return bindFunctionOrConstructorType(node); - case 160: - case 281: - case 265: + case 161: + case 170: + case 286: + case 270: return bindAnonymousDeclaration(node, 2048, "__type"); - case 172: + case 176: return bindObjectLiteralExpression(node); - case 180: - case 181: + case 184: + case 185: return bindFunctionExpression(node); - case 175: + case 179: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 193: - case 222: + case 197: + case 226: inStrictMode = true; return bindClassLikeDeclaration(node); - case 223: + case 227: return bindBlockScopedDeclaration(node, 64, 792968); - case 279: - case 224: + case 284: + if (!node.fullName || node.fullName.kind === 70) { + return bindBlockScopedDeclaration(node, 524288, 793064); + } + break; + case 228: return bindBlockScopedDeclaration(node, 524288, 793064); - case 225: - 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); + return bindEnumDeclaration(node); + case 230: + return bindModuleDeclaration(node); + case 234: case 237: - return bindExportDeclaration(node); + case 239: + case 243: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 233: + return bindNamespaceExportDeclaration(node); case 236: + return bindImportClause(node); + case 241: + return bindExportDeclaration(node); + case 240: return bindExportAssignment(node); - case 256: + case 261: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200: + case 204: if (!ts.isFunctionLike(node.parent)) { return; } - case 227: + case 231: return updateStrictModeStatementList(node.statements); } } @@ -18619,7 +20014,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166) { + if (parameterName && parameterName.kind === 167) { seenThisKeyword = true; } bind(type); @@ -18638,7 +20033,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 240 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18648,17 +20043,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 !== 261) { 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_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_7.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -18697,11 +20092,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 221 || container.kind === 180) { + if (container.kind === 225 || container.kind === 184) { 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); @@ -18741,7 +20136,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 222) { + if (node.kind === 226) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -18859,15 +20254,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 !== 206) || + node.kind === 226 || + (node.kind === 230 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 229 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 || + (node.kind !== 205 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18881,54 +20276,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175: - return computeCallExpression(node, subtreeFlags); - case 176: - return computeNewExpression(node, subtreeFlags); - case 226: - return computeModuleDeclaration(node, subtreeFlags); case 179: - return computeParenthesizedExpression(node, subtreeFlags); - case 188: - return computeBinaryExpression(node, subtreeFlags); - case 203: - return computeExpressionStatement(node, subtreeFlags); - case 143: - return computeParameter(node, subtreeFlags); - case 181: - return computeArrowFunction(node, subtreeFlags); + return computeCallExpression(node, subtreeFlags); case 180: - return computeFunctionExpression(node, subtreeFlags); - case 221: - 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 computeClassDeclaration(node, subtreeFlags); - case 193: - return computeClassExpression(node, subtreeFlags); - case 251: - return computeHeritageClause(node, subtreeFlags); - case 195: - return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149: - return computeConstructor(node, subtreeFlags); - case 146: - return computePropertyDeclaration(node, subtreeFlags); - case 148: - return computeMethod(node, subtreeFlags); - case 150: - case 151: - return computeAccessor(node, subtreeFlags); + return computeNewExpression(node, subtreeFlags); case 230: + return computeModuleDeclaration(node, subtreeFlags); + case 183: + return computeParenthesizedExpression(node, subtreeFlags); + case 192: + return computeBinaryExpression(node, subtreeFlags); + case 207: + return computeExpressionStatement(node, subtreeFlags); + case 144: + return computeParameter(node, subtreeFlags); + case 185: + return computeArrowFunction(node, subtreeFlags); + case 184: + return computeFunctionExpression(node, subtreeFlags); + case 225: + return computeFunctionDeclaration(node, subtreeFlags); + case 223: + return computeVariableDeclaration(node, subtreeFlags); + case 224: + return computeVariableDeclarationList(node, subtreeFlags); + case 205: + return computeVariableStatement(node, subtreeFlags); + case 219: + return computeLabeledStatement(node, subtreeFlags); + case 226: + return computeClassDeclaration(node, subtreeFlags); + case 197: + return computeClassExpression(node, subtreeFlags); + case 255: + return computeHeritageClause(node, subtreeFlags); + case 256: + return computeCatchClause(node, subtreeFlags); + case 199: + return computeExpressionWithTypeArguments(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 234: return computeImportEquals(node, subtreeFlags); - case 173: + case 177: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -18942,19 +20339,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 177: + case 178: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -18966,27 +20363,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 === 176) { + transformFlags |= 48 | 3072 | 49152; + } + else if (operatorTokenKind === 57 && leftKind === 175) { + 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; @@ -18996,33 +20394,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 === 200 + || expressionKind === 182) { 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; @@ -19031,36 +20432,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; @@ -19070,15 +20470,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 |= 3072; + } + node.transformFlags = transformFlags | 536870912; + 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; @@ -19087,10 +20495,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 @@ -19099,13 +20507,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; @@ -19116,15 +20524,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; @@ -19134,27 +20542,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; @@ -19164,54 +20572,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 === 172) { + transformFlags |= 48 | 3072 | 67108864; + } + else if (nameKind === 173) { + transformFlags |= 3072 | 67108864; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19222,24 +20639,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; @@ -19247,15 +20661,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; @@ -19264,26 +20678,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 189: + transformFlags |= 192; break; case 113: case 111: @@ -19291,52 +20705,49 @@ var ts; case 116: case 123: case 75: - case 225: - case 255: - case 178: - case 196: - case 197: - case 129: + case 229: + case 260: + case 182: + case 200: + case 201: + case 130: transformFlags |= 3; break; - case 242: - case 243: - case 244: - case 10: - case 245: case 246: case 247: case 248: + case 10: + case 249: + case 250: + case 251: + case 252: transformFlags |= 12; break; - case 83: - transformFlags |= 768 | 3; - break; - case 78: + case 213: + transformFlags |= 48; case 12: case 13: case 14: case 15: - case 190: - case 177: - case 254: - case 209: - transformFlags |= 768; + case 194: + case 181: + case 258: + case 114: + transformFlags |= 3072; break; - case 191: - transformFlags |= 768 | 16777216; + case 195: + 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: @@ -19350,73 +20761,142 @@ var ts; case 163: case 164: case 165: - case 223: - case 224: case 166: + case 227: + case 228: case 167: + case 168: + case 169: + case 170: + case 171: 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 196: + case 259: + transformFlags |= 8388608; break; + case 174: + 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; + transformFlags |= 262144; break; case 172: - excludeFlags = 539110741; - if (subtreeFlags & 2097152) { - transformFlags |= 768; + case 173: + if (subtreeFlags & 8388608) { + transformFlags |= 48 | 67108864; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + else { + transformFlags |= 3072 | 67108864; } break; - case 171: + case 145: + transformFlags |= 3 | 65536; + break; case 176: - excludeFlags = 537922901; + excludeFlags = 554784085; + if (subtreeFlags & 16777216) { + transformFlags |= 3072; + } if (subtreeFlags & 1048576) { - transformFlags |= 768; + transformFlags |= 262144; + } + if (subtreeFlags & 8388608) { + transformFlags |= 48; } break; - case 205: - case 206: - case 207: - case 208: - if (subtreeFlags & 4194304) { - transformFlags |= 768; + case 175: + case 180: + excludeFlags = 545281365; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } break; - case 256: - if (subtreeFlags & 65536) { - transformFlags |= 768; - } - break; - case 212: + case 209: case 210: case 211: - transformFlags |= 33554432; + case 212: + if (subtreeFlags & 33554432) { + transformFlags |= 3072; + } + break; + case 261: + if (subtreeFlags & 524288) { + transformFlags |= 3072; + } + break; + case 216: + case 214: + case 215: + transformFlags |= 268435456; break; } node.transformFlags = transformFlags | 536870912; return transformFlags & ~excludeFlags; } + function getTransformFlagsSubtreeExclusions(kind) { + if (kind >= 156 && kind <= 171) { + return -3; + } + switch (kind) { + case 179: + case 180: + case 175: + return 545281365; + case 230: + return 839734613; + case 144: + return 604001621; + case 185: + return 979719509; + case 184: + case 225: + return 980243797; + case 224: + return 604001621; + case 226: + case 197: + return 559895893; + case 150: + return 975983957; + case 149: + case 151: + 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 155: + case 227: + case 228: + return -3; + case 176: + return 554784085; + default: + return 536892757; + } + } + ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; })(ts || (ts = {})); var ts; (function (ts) { @@ -19504,7 +20984,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(); @@ -19518,9 +21001,9 @@ var ts; var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 33554432, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 2097152, "undefined"); var nullType = createIntrinsicType(4096, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 33554432, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 2097152, "null"); var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var trueType = createIntrinsicType(128, "true"); @@ -19530,11 +21013,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 |= 134217728; + 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); @@ -19596,66 +21083,6 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; - TypeFacts[TypeFacts["All"] = 8388607] = "All"; - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -19682,6 +21109,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", @@ -19698,17 +21127,25 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); 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; @@ -19789,7 +21226,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { + (target.valueDeclaration.kind === 230 && source.valueDeclaration.kind !== 230))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -19845,7 +21282,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; } @@ -19882,8 +21319,11 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } + function getObjectFlags(type) { + return type.flags & 32768 ? type.objectFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 256 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 261 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -19920,36 +21360,39 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } + if (isUsedInFunctionOrNonStaticProperty(usage)) { + return true; + } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 219 || + return declaration.kind !== 223 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } - return isUsedInFunctionOrNonStaticProperty(declaration, usage); + var container = ts.getEnclosingBlockScopeContainer(declaration); + return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201: - case 207: - case 209: + case 205: + case 211: + case 213: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 208: - case 209: + case 212: + case 213: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); + function isUsedInFunctionOrNonStaticProperty(usage, container) { var current = usage; while (current) { if (current === container) { @@ -19959,7 +21402,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) { @@ -19982,18 +21425,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 !== 278) { 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) { @@ -20005,13 +21448,13 @@ var ts; } } switch (location.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226: + case 230: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 || ts.isAmbientModule(location)) { + if (location.kind === 261 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20021,7 +21464,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 239)) { + ts.getDeclarationOfKind(moduleExports[name], 243)) { break; } } @@ -20029,13 +21472,13 @@ var ts; break loop; } break; - case 225: + case 229: 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) { @@ -20045,9 +21488,9 @@ var ts; } } break; - case 222: - case 193: - case 223: + case 226: + case 197: + case 227: 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); @@ -20055,7 +21498,7 @@ var ts; } break loop; } - if (location.kind === 193 && meaning & 32) { + if (location.kind === 197 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20063,28 +21506,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 === 227) { 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 225: + case 185: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180: + case 184: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20097,8 +21540,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)) { @@ -20140,7 +21583,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 === 233) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20187,9 +21630,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 173: + case 177: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195: + case 199: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20210,7 +21653,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, 223), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20227,10 +21670,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230) { + if (node.kind === 234) { return node; } - while (node && node.kind !== 231) { + while (node && node.kind !== 235) { node = node.parent; } return node; @@ -20240,7 +21683,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 === 245) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20301,28 +21744,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_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_13.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_19.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_19.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_13.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_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); + error(name_19, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_19)); } return symbol; } @@ -20344,19 +21787,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230: + case 234: return getTargetOfImportEqualsDeclaration(node); - case 232: - return getTargetOfImportClause(node); - case 233: - return getTargetOfNamespaceImport(node); - case 235: - return getTargetOfImportSpecifier(node); - case 239: - return getTargetOfExportSpecifier(node); case 236: + return getTargetOfImportClause(node); + case 237: + return getTargetOfNamespaceImport(node); + case 239: + return getTargetOfImportSpecifier(node); + case 243: + return getTargetOfExportSpecifier(node); + case 240: return getTargetOfExportAssignment(node); - case 229: + case 233: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20400,10 +21843,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236) { + if (node.kind === 240) { checkExpressionCached(node.expression); } - else if (node.kind === 239) { + else if (node.kind === 243) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20415,11 +21858,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 === 234); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20438,9 +21881,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 === 177) { + 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; @@ -20465,27 +21908,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); @@ -20501,14 +21945,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; @@ -20623,7 +22083,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; } } @@ -20645,8 +22105,9 @@ var ts; type.intrinsicName = "boolean"; return type; } - function createObjectType(kind, symbol) { - var type = createType(kind); + function createObjectType(objectFlags, symbol) { + var type = createType(32768); + type.objectFlags = objectFlags; type.symbol = symbol; return type; } @@ -20670,7 +22131,7 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; @@ -20682,7 +22143,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - return setObjectTypeMembers(createObjectType(2097152, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -20693,11 +22154,11 @@ var ts; } } switch (location_1.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226: + case 230: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -20730,7 +22191,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 243)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -20761,7 +22222,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, 243)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -20775,10 +22236,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; @@ -20834,7 +22295,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 261 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -20868,11 +22329,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 === 177 || + entityName.parent.kind === 234) { meaning = 1920; } else { @@ -20964,10 +22425,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 === 228) { return getSymbolOfNode(node); } } @@ -20975,7 +22436,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 && + node.parent.kind === 231 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -20989,10 +22450,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193: + case 197: return "(Anonymous class)"; - case 180: - case 181: + case 184: + case 185: return "(Anonymous function)"; } } @@ -21044,9 +22505,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_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21087,7 +22548,7 @@ var ts; } writer.writeKeyword("this"); } - else if (type.flags & 131072) { + else if (getObjectFlags(type) & 4) { writeTypeReference(type, nextFlags); } else if (type.flags & 256) { @@ -21095,23 +22556,34 @@ var ts; writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } - else if (type.flags & (32768 | 65536 | 16 | 16384)) { + else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && ((type.flags & 2097152 && !type.target) || type.flags & 1572864) && type.aliasSymbol && + else if (!(flags & 512) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } - else if (type.flags & 1572864) { + else if (type.flags & 196608) { writeUnionOrIntersectionType(type, nextFlags); } - else if (type.flags & 2097152) { + else if (getObjectFlags(type) & (16 | 32)) { writeAnonymousType(type, nextFlags); } 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); @@ -21156,7 +22628,7 @@ var ts; writePunctuation(writer, 20); writePunctuation(writer, 21); } - else if (type.target.flags & 262144) { + else if (type.target.objectFlags & 8) { writePunctuation(writer, 20); writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); writePunctuation(writer, 21); @@ -21168,12 +22640,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21186,7 +22658,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 18); } - if (type.flags & 524288) { + if (type.flags & 65536) { writeTypeList(formatUnionTypes(type.types), 48); } else { @@ -21232,7 +22704,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 === 261 || declaration.parent.kind === 231; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21248,7 +22720,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } writePunctuation(writer, 20); @@ -21266,7 +22738,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -21286,6 +22758,12 @@ var ts; return false; } function writeLiteralType(type, flags) { + if (type.objectFlags & 32) { + if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { + writeMappedType(type); + return; + } + } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { @@ -21322,6 +22800,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); @@ -21334,8 +22818,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); @@ -21358,9 +22842,32 @@ var ts; writer.writeLine(); } } + } + function writeMappedType(type) { + writePunctuation(writer, 16); + writer.writeLine(); + writer.increaseIndent(); + if (type.declaration.readonlyToken) { + writeKeyword(writer, 130); + writeSpace(writer); + } + writePunctuation(writer, 20); + appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); + writeSpace(writer); + writeKeyword(writer, 91); + writeSpace(writer); + writeType(getConstraintTypeFromMappedType(type), 0); + writePunctuation(writer, 21); + if (type.declaration.questionToken) { + writePunctuation(writer, 54); + } + writePunctuation(writer, 55); + writeSpace(writer); + writeType(getTemplateTypeFromMappedType(type), 0); + writePunctuation(writer, 24); + writer.writeLine(); writer.decreaseIndent(); writePunctuation(writer, 17); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -21398,12 +22905,12 @@ var ts; buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 172) { 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 === 173) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -21417,7 +22924,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170); + ts.Debug.assert(bindingElement.kind === 174); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55); @@ -21545,63 +23052,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170: + case 174: return isDeclarationVisible(node.parent.parent); - case 219: + case 223: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 226: - case 222: - case 223: - case 224: - case 221: - case 225: case 230: + case 226: + case 227: + case 228: + case 225: + case 229: + case 234: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_8 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 234 && parent_8.kind !== 261 && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } - return isDeclarationVisible(parent_10); - case 146: - case 145: - case 150: - case 151: - case 148: + return isDeclarationVisible(parent_8); 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 231: 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 237: + case 239: + return false; + case 143: + case 261: + case 233: + return true; + case 240: return false; default: return false; @@ -21610,10 +23117,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236) { + if (node.parent && node.parent.kind === 240) { 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 === 243) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -21675,7 +23182,6 @@ var ts; return getSymbolLinks(target).declaredType; } if (propertyName === 1) { - ts.Debug.assert(!!(target.flags & 32768)); return target.resolvedBaseConstructorType; } if (propertyName === 3) { @@ -21692,12 +23198,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219: - case 220: - case 235: - case 234: - case 233: - case 232: + case 223: + case 224: + case 239: + case 238: + case 237: + case 236: node = node.parent; break; default: @@ -21723,22 +23229,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; @@ -21753,26 +23267,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 === 172) { + 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 !== 198 && !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_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) @@ -21787,9 +23320,6 @@ var ts; return unknownType; } } - else { - type = createArrayType(elementType); - } } if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) { type = getTypeWithFacts(type, 131072); @@ -21809,15 +23339,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 === 223 && + declaration.parent.kind === 224 && + declaration.parent.parent.kind === 205) { 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; @@ -21831,22 +23361,22 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 && expr.elements.length === 0; + return expr.kind === 175 && 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 === 212) { return stringType; } - if (declaration.parent.parent.kind === 209) { + if (declaration.parent.parent.kind === 213) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -21855,7 +23385,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 === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -21864,10 +23394,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); @@ -21893,7 +23423,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 254) { + if (declaration.kind === 258) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -21918,11 +23448,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); @@ -21934,7 +23464,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= 512; } return result; } @@ -21953,7 +23483,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 + return pattern.kind === 172 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -21963,7 +23493,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 253) { + if (declaration.kind === 257) { return type; } return getWidenedType(type); @@ -21978,7 +23508,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) { @@ -21988,28 +23518,28 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 252) { + if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 236) { + if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 285 && 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 === 192 || + declaration.kind === 177 && declaration.parent.kind === 192) { + 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 === 192 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22035,7 +23565,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150) { + if (accessor.kind === 151) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22055,9 +23585,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; @@ -22097,7 +23627,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)); } } @@ -22108,11 +23638,11 @@ 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 { - var type = createObjectType(2097152, symbol); + var type = createObjectType(16, symbol); links.type = strictNullChecks && symbol.flags & 536870912 ? includeFalsyTypes(type, 2048) : type; } @@ -22165,7 +23695,7 @@ var ts; return unknownType; } function getTargetType(type) { - return type.flags & 131072 ? type.target : type; + return getObjectFlags(type) & 4 ? type.target : type; } function hasBaseType(type, checkBase) { return check(type); @@ -22193,9 +23723,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 === 226 || node.kind === 197 || + node.kind === 225 || node.kind === 184 || + node.kind === 149 || node.kind === 185) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22204,15 +23734,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, 227); 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 === 227 || node.kind === 226 || + node.kind === 197 || node.kind === 228) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22225,7 +23755,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 2588672 && getSignaturesOfType(type, 1).length > 0; + return type.flags & 32768 && getSignaturesOfType(type, 1).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -22237,7 +23767,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; @@ -22252,7 +23782,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 2588672) { + if (baseConstructorType.flags & 32768) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -22269,7 +23799,7 @@ var ts; } function getBaseTypes(type) { if (!type.resolvedBaseTypes) { - if (type.flags & 262144) { + if (type.objectFlags & 8) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } else if (type.symbol.flags & (32 | 64)) { @@ -22289,7 +23819,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 2588672)) { + if (!(baseConstructorType.flags & 32768)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -22310,7 +23840,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getTargetType(baseType).flags & (32768 | 65536))) { + if (!(getObjectFlags(getTargetType(baseType)) & 3)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -22338,12 +23868,12 @@ 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 === 227 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (32768 | 65536)) { + if (getObjectFlags(getTargetType(baseType)) & 3) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -22367,7 +23897,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 === 227) { if (declaration.flags & 64) { return false; } @@ -22390,12 +23920,12 @@ var ts; function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var kind = symbol.flags & 32 ? 32768 : 65536; + var kind = symbol.flags & 32 ? 1 : 2; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters || kind === 32768 || !isIndependentInterface(symbol)) { - type.flags |= 131072; + if (outerTypeParameters || localTypeParameters || kind === 1 || !isIndependentInterface(symbol)) { + type.objectFlags |= 4; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -22417,8 +23947,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279); + var declaration = ts.getDeclarationOfKind(symbol, 284); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -22429,14 +23958,15 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224); - type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); + declaration = ts.getDeclarationOfKind(symbol, 228); + type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { - links.typeParameters = typeParameters; + var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { + links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(links.typeParameters)] = type; + links.instantiations[getTypeListId(typeParameters)] = type; } } else { @@ -22453,14 +23983,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 190 && 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 === 229) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22488,7 +24018,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 === 229) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22503,7 +24033,7 @@ var ts; } enumType.memberTypes = memberTypes; if (memberTypeList.length > 1) { - enumType.flags |= 524288; + enumType.flags |= 65536; enumType.types = memberTypeList; unionTypes[getTypeListId(memberTypeList)] = enumType; } @@ -22515,7 +24045,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - links.declaredType = enumType.flags & 524288 ? + links.declaredType = enumType.flags & 65536 ? enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : enumType; } @@ -22526,7 +24056,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; @@ -22576,19 +24106,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 171: return true; - case 161: + case 162: return isIndependentType(node.elementType); - case 156: + case 157: return isIndependentTypeReference(node); } return false; @@ -22597,7 +24127,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++) { @@ -22613,12 +24143,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); } } @@ -22661,7 +24191,7 @@ var ts; return type; } function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 131072) { + if (getObjectFlags(type) & 4) { return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); } return type; @@ -22684,8 +24214,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); } @@ -22705,7 +24235,7 @@ var ts; numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -22740,14 +24270,14 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNodeNoAlias); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { 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); @@ -22832,7 +24362,7 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1); var stringIndexInfo = getUnionIndexInfo(type.types, 0); var numberIndexInfo = getUnionIndexInfo(type.types, 1); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); @@ -22840,6 +24370,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; @@ -22852,17 +24385,17 @@ var ts; stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { 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); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { var members = symbol.members; @@ -22870,7 +24403,7 @@ var ts; var constructSignatures = getSignaturesOfSymbol(members["__new"]); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { var members = emptySymbols; @@ -22885,46 +24418,106 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 2588672) { + if (baseConstructorType.flags & 32768) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } } } + function resolveMappedTypeMembers(type) { + var members = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + var typeParameter = getTypeParameterFromMappedType(type); + var constraintType = getConstraintTypeFromMappedType(type); + var templateType = getTemplateTypeFromMappedType(type); + var isReadonly = !!type.declaration.readonlyToken; + var isOptional = !!type.declaration.questionToken; + var keyType = constraintType.flags & 16384 ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 262144 ? getIndexType(getApparentType(keyType.type)) : keyType; + forEachType(iterationType, function (t) { + var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; + var propType = instantiateType(templateType, templateMapper); + if (t.flags & (32 | 64 | 256)) { + var propName = t.text; + var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); + prop.type = addOptionality(propType, isOptional); + prop.isReadonly = isReadonly; + members[propName] = prop; + } + else if (t.flags & 2) { + stringIndexInfo = createIndexInfo(propType, isReadonly); + } + else if (t.flags & 4) { + numberIndexInfo = createIndexInfo(propType, isReadonly); + } + }); + if (stringIndexInfo && numberIndexInfo && isTypeIdenticalTo(stringIndexInfo.type, numberIndexInfo.type)) { + numberIndexInfo = undefined; + } + setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } + function getTypeParameterFromMappedType(type) { + return type.typeParameter || + (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter))); + } + function getConstraintTypeFromMappedType(type) { + return type.constraintType || + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + } + function getTemplateTypeFromMappedType(type) { + return type.templateType || + (type.templateType = type.declaration.type ? + instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + unknownType); + } + function isGenericMappedType(type) { + if (getObjectFlags(type) & 32) { + var constraintType = getConstraintTypeFromMappedType(type); + return !!(constraintType.flags & (16384 | 262144)); + } + return false; + } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072) { - resolveTypeReferenceMembers(type); + if (type.flags & 32768) { + if (type.objectFlags & 4) { + resolveTypeReferenceMembers(type); + } + else if (type.objectFlags & 3) { + resolveClassOrInterfaceMembers(type); + } + else if (type.objectFlags & 16) { + resolveAnonymousTypeMembers(type); + } + else if (type.objectFlags & 32) { + resolveMappedTypeMembers(type); + } } - else if (type.flags & (32768 | 65536)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 2097152) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 524288) { + else if (type.flags & 65536) { resolveUnionTypeMembers(type); } - else if (type.flags & 1048576) { + else if (type.flags & 131072) { resolveIntersectionTypeMembers(type); } } return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { return resolveStructuredTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -22939,7 +24532,7 @@ var ts; var prop = _c[_b]; getUnionOrIntersectionProperty(type, prop.name); } - if (type.flags & 524288) { + if (type.flags & 65536) { break; } } @@ -22958,7 +24551,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 1572864 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { @@ -22971,27 +24566,18 @@ 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; var props; - var commonFlags = (containingType.flags & 1048576) ? 536870912 : 0; + var commonFlags = (containingType.flags & 131072) ? 536870912 : 0; var isReadonly = false; var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { @@ -23011,7 +24597,7 @@ var ts; isReadonly = true; } } - else if (containingType.flags & 524288) { + else if (containingType.flags & 65536) { isPartial = true; } } @@ -23046,7 +24632,7 @@ var ts; result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; - result.type = containingType.flags & 524288 ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = containingType.flags & 65536 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } function getUnionOrIntersectionProperty(type, name) { @@ -23066,7 +24652,7 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -23080,13 +24666,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 1572864) { + if (type.flags & 196608) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 4161536) { + if (type.flags & 229376) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -23096,7 +24682,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 4161536) { + if (type.flags & 229376) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -23127,7 +24713,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); @@ -23155,8 +24741,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 === 273) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -23165,11 +24751,18 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268; + return paramTag.typeExpression.type.kind === 273; } } } } + 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; @@ -23223,7 +24816,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167) { + if (param.type && param.type.kind === 171) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23235,10 +24828,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); @@ -23250,14 +24843,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); @@ -23274,14 +24867,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)) { @@ -23295,20 +24888,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 225: 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 184: + case 185: + case 274: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -23369,13 +24962,18 @@ var ts; function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 131072 && type.target === globalArrayType) { + if (getObjectFlags(type) & 4 && type.target === globalArrayType) { return type.typeArguments[0]; } } 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) { @@ -23388,8 +24986,8 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; - var type = createObjectType(2097152); + var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; + var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -23402,7 +25000,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++) { @@ -23429,7 +25027,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; @@ -23462,7 +25060,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 = ""; @@ -23495,22 +25093,23 @@ var ts; result |= type.flags; } } - return result & 234881024; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var propagatedFlags = typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; - var flags = 131072 | propagatedFlags; - type = target.instantiations[id] = createObjectType(flags, target.symbol); + type = target.instantiations[id] = createObjectType(4, target.symbol); + type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; type.typeArguments = typeArguments; } return type; } function cloneTypeReference(source) { - var type = createObjectType(source.flags, source.symbol); + var type = createType(source.flags); + type.symbol = source.symbol; + type.objectFlags = source.objectFlags; type.target = source.target; type.typeArguments = source.typeArguments; return type; @@ -23526,7 +25125,7 @@ var ts; error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1), typeParameters.length); return unknownType; } - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias))); + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -23534,18 +25133,23 @@ var ts; } return type; } - function getTypeFromTypeAliasReference(node, symbol) { + function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } + function getTypeFromTypeAliasReference(node, symbol) { + var type = getDeclaredTypeOfSymbol(symbol); + var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); return unknownType; } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + return getTypeAliasInstantiation(symbol, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); @@ -23562,11 +25166,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156: + case 157: return node.typeName; - case 267: + case 272: return node.name; - case 195: + case 199: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23590,7 +25194,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 267) { + if (symbol.flags & 107455 && node.kind === 272) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -23600,13 +25204,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267) { + if (node.kind === 272) { 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 @@ -23635,9 +25239,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 227: + case 229: return declaration; } } @@ -23646,7 +25250,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 2588672)) { + if (!(type.flags & 32768)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -23709,7 +25313,7 @@ var ts; property.type = typeParameter; properties.push(property); } - var type = createObjectType(262144 | 131072); + var type = createObjectType(8 | 4); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -23736,7 +25340,7 @@ var ts; function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNodeNoAlias)); + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); } return links.resolvedType; } @@ -23764,7 +25368,7 @@ var ts; } function addTypeToUnion(typeSet, type) { var flags = type.flags; - if (flags & 524288) { + if (flags & 65536) { addTypesToUnion(typeSet, type.types); } else if (flags & 1) { @@ -23775,7 +25379,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096) typeSet.containsNull = true; - if (!(flags & 33554432)) + if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192)) { @@ -23788,7 +25392,8 @@ var ts; var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & 2097152 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { + if (!(flags & 32768 && type.objectFlags & 16 && + type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } } @@ -23850,7 +25455,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 && types.containsString || t.flags & 64 && types.containsNumber || - t.flags & 96 && t.flags & 16777216 && containsType(types, t.regularType); + t.flags & 96 && t.flags & 1048576 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -23892,22 +25497,22 @@ var ts; var type = unionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, 6144); - type = unionTypes[id] = createObjectType(524288 | propagatedFlags); + type = unionTypes[id] = createType(65536 | propagatedFlags); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), false, aliasSymbol, aliasTypeArguments); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), false, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } function addTypeToIntersection(typeSet, type) { - if (type.flags & 1048576) { + if (type.flags & 131072) { addTypesToIntersection(typeSet, type.types); } else if (type.flags & 1) { @@ -23927,6 +25532,17 @@ var ts; if (types.length === 0) { return emptyObjectType; } + 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_2(i); + if (typeof state_2 === "object") + return state_2.value; + } var typeSet = []; addTypesToIntersection(typeSet, types); if (typeSet.containsAny) { @@ -23939,39 +25555,248 @@ var ts; var type = intersectionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 6144); - type = intersectionTypes[id] = createObjectType(1048576 | propagatedFlags); + type = intersectionTypes[id] = createType(131072 | propagatedFlags); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), aliasSymbol, aliasTypeArguments); + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return getDeclarationModifierFlagsFromSymbol(prop) & 24 || 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) { - var type = createObjectType(2097152, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = getIndexType(getTypeFromTypeNode(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 === 178 ? 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 === 178 ? 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 (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + 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(getTypeFromTypeNode(node.objectType), getTypeFromTypeNode(node.indexType), node); + } + return links.resolvedType; + } + function getTypeFromMappedTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = createObjectType(32, node.symbol); + type.declaration = node; + type.aliasSymbol = getAliasSymbolForTypeNode(node); + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); links.resolvedType = type; } return links.resolvedType; } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + links.resolvedType = type; + } + } + return links.resolvedType; + } + function getAliasSymbolForTypeNode(node) { + return node.parent.kind === 228 ? getSymbolOfNode(node.parent) : undefined; + } + function getAliasTypeArgumentsForTypeNode(node) { + var symbol = getAliasSymbolForTypeNode(node); + return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; + } + 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 & 16777216)) { + if (type.flags & 96 && !(type.flags & 1048576)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 16777216, type.text); + var freshType = createLiteralType(type.flags | 1048576, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -23980,7 +25805,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 16777216 ? type.regularType : type; + return type.flags & 96 && type.flags & 1048576 ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; @@ -24004,7 +25829,7 @@ var ts; function getTypeFromJSDocTupleType(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var types = ts.map(node.types, getTypeFromTypeNodeNoAlias); + var types = ts.map(node.types, getTypeFromTypeNode); links.resolvedType = createTupleType(types); } return links.resolvedType; @@ -24012,9 +25837,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 === 227)) { 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; } } @@ -24028,85 +25853,88 @@ var ts; } return links.resolvedType; } - function getTypeFromTypeNodeNoAlias(type) { - return getTypeFromTypeNode(type, undefined, undefined); - } - function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromTypeNode(node) { switch (node.kind) { case 118: - case 258: - case 259: + case 263: + case 264: 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 288: return nullType; - case 284: + case 289: return undefinedType; - case 285: + case 290: return neverType; - case 166: + case 167: case 98: return getTypeFromThisTypeNode(node); - case 167: + case 171: return getTypeFromLiteralTypeNode(node); - case 282: + case 287: 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 272: + return getTypeFromTypeReference(node); + case 156: + return booleanType; + case 199: + return getTypeFromTypeReference(node); case 160: - case 281: + return getTypeFromTypeQueryNode(node); + case 162: + case 265: + return getTypeFromArrayTypeNode(node); + case 163: + return getTypeFromTupleTypeNode(node); + case 164: + case 266: + return getTypeFromUnionTypeNode(node); + case 165: + return getTypeFromIntersectionTypeNode(node); + case 166: + case 268: case 269: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 276: + case 277: + case 273: + return getTypeFromTypeNode(node.type); + case 270: + return getTypeFromTypeNode(node.literal); + case 158: + case 159: + case 161: + case 286: + case 274: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 168: + return getTypeFromTypeOperatorNode(node); + case 169: + return getTypeFromIndexedAccessTypeNode(node); + case 170: + return getTypeFromMappedTypeNode(node); case 70: - case 140: + case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262: + case 267: return getTypeFromJSDocTupleType(node); - case 270: + case 275: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24123,6 +25951,16 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } + function instantiateCached(type, mapper, instantiator) { + var instantiations = mapper.instantiations || (mapper.instantiations = []); + return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -24145,7 +25983,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) { @@ -24235,45 +26072,46 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - var result = createObjectType(2097152 | 4194304, type.symbol); - result.target = type; - result.mapper = mapper; + var result = createObjectType(16 | 64, type.symbol); + result.target = type.objectFlags & 64 ? type.target : type; + result.mapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; - mapper.instantiations[type.id] = result; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + return result; + } + function instantiateMappedType(type, mapper) { + var result = createObjectType(32 | 64, type.symbol); + result.declaration = type.declaration; + result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + result.aliasSymbol = type.aliasSymbol; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); 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 225: 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 184: + case 185: + case 226: + case 197: + case 227: + case 228: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24283,69 +26121,97 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223) { + if (ts.isClassLike(node) || node.kind === 227) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226: - case 256: + case 230: + case 261: return false; } node = node.parent; } return false; } + function isTopLevelTypeAlias(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var parentKind = symbol.declarations[0].parent.kind; + return parentKind === 261 || parentKind === 231; + } + return false; + } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.flags & 16384) { - return mapper(type); + if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { + if (type.aliasTypeArguments) { + return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + return type; } - if (type.flags & 2097152) { + return instantiateTypeNoAlias(type, mapper); + } + return type; + } + function instantiateTypeNoAlias(type, mapper) { + if (type.flags & 16384) { + return mapper(type); + } + if (type.flags & 32768) { + if (type.objectFlags & 16) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && - (type.flags & 4194304 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateAnonymousType(type, mapper) : type; + (type.objectFlags & 64 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? + instantiateCached(type, mapper, instantiateAnonymousType) : type; } - if (type.flags & 131072) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + if (type.objectFlags & 32) { + return instantiateCached(type, mapper, instantiateMappedType); } - if (type.flags & 524288 && !(type.flags & 8190)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), false, type.aliasSymbol, mapper.targetTypes); - } - if (type.flags & 1048576) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + if (type.objectFlags & 4) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } + if (type.flags & 65536 && !(type.flags & 8190)) { + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 131072) { + 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; } function instantiateIndexInfo(info, mapper) { 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 184: + case 185: return isContextSensitiveFunctionLikeDeclaration(node); - case 172: + case 176: return ts.forEach(node.properties, isContextSensitive); - case 171: + case 175: return ts.forEach(node.elements, isContextSensitive); - case 189: + case 193: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188: + case 192: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253: + case 257: return isContextSensitive(node.initializer); + case 149: case 148: - case 147: return isContextSensitiveFunctionLikeDeclaration(node); - case 179: + case 183: return isContextSensitive(node.expression); } return false; @@ -24357,7 +26223,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 181) { + if (node.kind === 185) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -24367,10 +26233,10 @@ var ts; return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(2097152, type.symbol); + var result = createObjectType(16, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -24549,7 +26415,7 @@ var ts; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256) || - (source.flags & 524288) !== (target.flags & 524288)) { + (source.flags & 65536) !== (target.flags & 65536)) { return enumRelation[id] = false; } var targetEnumType = getTypeOfSymbol(target.symbol); @@ -24606,23 +26472,23 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 16777216) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 16777216) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 2588672 && target.flags & 2588672) { + if (source.flags & 32768 && target.flags & 32768) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related === 1; } } - if (source.flags & 4177920 || target.flags & 4177920) { + if (source.flags & 507904 || target.flags & 507904) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -24659,9 +26525,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); } @@ -24677,10 +26549,10 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 && source.flags & 16777216) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 16777216) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target) @@ -24690,19 +26562,24 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (source.flags & 8388608 && source.flags & 16777216) { + if (source.flags & 262144) { + if (maybeTypeOfKind(target, 2) && maybeTypeOfKind(target, 4)) { + return -1; + } + } + if (getObjectFlags(source) & 128 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); } return 0; } - if (target.flags & 1572864) { + if (target.flags & 196608) { source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 524288) { + if (source.flags & 65536) { if (relation === comparableRelation) { result = someTypeRelatedToType(source, target, reportErrors && !(source.flags & 8190)); } @@ -24713,20 +26590,38 @@ var ts; return result; } } - else if (target.flags & 1048576) { - result = typeRelatedToEachType(source, target, reportErrors); - if (result) { + else if (target.flags & 65536) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { return result; } } - else { - if (source.flags & 1048576) { - if (result = someTypeRelatedToType(source, target, false)) { + else if (target.flags & 131072) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072) { + if (result = someTypeRelatedToType(source, target, false)) { + return result; + } + } + if (target.flags & 16384) { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { return result; } } - if (target.flags & 524288) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { + } + else if (target.flags & 262144) { + if (source.flags & 262144) { + if (result = isRelatedTo(target.type, source.type, false)) { + return result; + } + } + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { return result; } } @@ -24744,25 +26639,35 @@ var ts; } } else { - if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } - var apparentSource = getApparentType(source); - if (apparentSource.flags & (2588672 | 1048576) && target.flags & 2588672) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; + if (isGenericMappedType(target)) { + if (isGenericMappedType(source)) { + if ((result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) && + (result = isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors))) { + return result; + } + } + } + else { + var apparentSource = getApparentType(source); + if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } if (reportErrors) { - if (source.flags & 2588672 && target.flags & 8190) { + if (source.flags & 32768 && target.flags & 8190) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 2588672 && globalObjectType === source) { + else if (source.symbol && source.flags & 32768 && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } reportRelationError(headMessage, source, target); @@ -24771,16 +26676,16 @@ var ts; } function isIdenticalTo(source, target) { var result; - if (source.flags & 2588672 && target.flags & 2588672) { - if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + if (source.flags & 32768 && target.flags & 32768) { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { if (result = typeArgumentsRelatedTo(source, target, false)) { return result; } } return objectTypeRelatedTo(source, source, target, false); } - if (source.flags & 524288 && target.flags & 524288 || - source.flags & 1048576 && target.flags & 1048576) { + if (source.flags & 65536 && target.flags & 65536 || + source.flags & 131072 && target.flags & 131072) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -24790,7 +26695,7 @@ var ts; return 0; } function isKnownProperty(type, name) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || @@ -24799,7 +26704,7 @@ var ts; return true; } } - else if (type.flags & 1572864) { + else if (type.flags & 196608) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name)) { @@ -24817,8 +26722,7 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (maybeTypeOfKind(target, 2588672) && - (!(target.flags & 2588672) || !target.isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -24848,7 +26752,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 524288 && containsType(targetTypes, source)) { + if (target.flags & 65536 && containsType(targetTypes, source)) { return -1; } var len = targetTypes.length; @@ -24875,7 +26779,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 524288 && containsType(sourceTypes, target)) { + if (source.flags & 65536 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; @@ -24995,9 +26899,9 @@ var ts; } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 8388608); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); + 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) { @@ -25049,7 +26953,7 @@ var ts; return 0; } result &= related; - if (sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { + if (relation !== comparableRelation && sourceProp.flags & 536870912 && !(targetProp.flags & 536870912)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -25061,7 +26965,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 2588672 && target.flags & 2588672)) { + if (!(source.flags & 32768 && target.flags & 32768)) { return 0; } var sourceProperties = getPropertiesOfObjectType(source); @@ -25233,7 +27137,7 @@ var ts; } } function isAbstractConstructorType(type) { - if (type.flags & 2097152) { + if (getObjectFlags(type) & 16) { var symbol = type.symbol; if (symbol && symbol.flags & 32) { var declaration = getClassLikeDeclarationOfSymbol(symbol); @@ -25245,12 +27149,12 @@ var ts; return false; } function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (131072 | 4194304) && depth >= 5) { + if (getObjectFlags(type) & (4 | 64) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (131072 | 4194304) && t.symbol === symbol) { + if (getObjectFlags(t) & (4 | 64) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -25408,10 +27312,10 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isArrayType(type) { - return type.flags & 131072 && type.target === globalArrayType; + return getObjectFlags(type) & 4 && type.target === globalArrayType; } function isArrayLikeType(type) { - return type.flags & 131072 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + return getObjectFlags(type) & 4 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || !(type.flags & 6144) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { @@ -25422,7 +27326,7 @@ var ts; } function isLiteralType(type) { return type.flags & 8 ? true : - type.flags & 524288 ? type.flags & 16 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + type.flags & 65536 ? type.flags & 16 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { @@ -25430,19 +27334,19 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 32 && type.flags & 16777216 ? stringType : - type.flags & 64 && type.flags & 16777216 ? 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 & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { - return !!(type.flags & 131072 && type.target.flags & 262144); + return !!(getObjectFlags(type) & 4 && type.target.objectFlags & 8); } function getFalsyFlagsOfTypes(types) { var result = 0; @@ -25453,7 +27357,7 @@ var ts; return result; } function getFalsyFlags(type) { - return type.flags & 524288 ? getFalsyFlagsOfTypes(type.types) : + return type.flags & 65536 ? getFalsyFlagsOfTypes(type.types) : type.flags & 32 ? type.text === "" ? 32 : 0 : type.flags & 64 ? type.text === "0" ? 64 : 0 : type.flags & 128 ? type === falseType ? 128 : 0 : @@ -25514,7 +27418,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(type.flags & 8388608 && type.flags & 16777216)) { + if (!(getObjectFlags(type) & 128 && type.flags & 1048576)) { return type; } var regularType = type.regularType; @@ -25524,7 +27428,8 @@ 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 & ~16777216; + regularNew.flags = resolved.flags & ~1048576; + regularNew.objectFlags |= 128; type.regularType = regularNew; return regularNew; } @@ -25541,14 +27446,14 @@ var ts; return type.flags & 6144 ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 100663296) { + if (type.flags & 6291456) { if (type.flags & 6144) { return anyType; } - if (type.flags & 8388608) { + if (getObjectFlags(type) & 128) { return getWidenedTypeOfObjectLiteral(type); } - if (type.flags & 524288) { + if (type.flags & 65536) { return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { @@ -25559,7 +27464,7 @@ var ts; } function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 524288) { + if (type.flags & 65536) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (reportWideningErrorsInType(t)) { @@ -25575,11 +27480,11 @@ var ts; } } } - if (type.flags & 8388608) { + if (getObjectFlags(type) & 128) { for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 33554432) { + 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))); } @@ -25593,25 +27498,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 174: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221: + case 225: + case 149: case 148: - case 147: - case 150: case 151: - case 180: - case 181: + case 152: + case 184: + case 185: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25624,7 +27529,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 33554432) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -25668,10 +27573,12 @@ var ts; }; } function couldContainTypeParameters(type) { + var objectFlags = getObjectFlags(type); return !!(type.flags & 16384 || - type.flags & 131072 && ts.forEach(type.typeArguments, couldContainTypeParameters) || - type.flags & 2097152 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) || - type.flags & 1572864 && couldUnionOrIntersectionContainTypeParameters(type)); + objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeParameters) || + objectFlags & 16 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) || + objectFlags & 32 || + type.flags & 196608 && couldUnionOrIntersectionContainTypeParameters(type)); } function couldUnionOrIntersectionContainTypeParameters(type) { if (type.couldContainTypeParameters === undefined) { @@ -25680,7 +27587,7 @@ var ts; return type.couldContainTypeParameters; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 1572864 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || type.flags & 196608 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function inferTypes(context, originalSource, originalTarget) { var typeParameters = context.signature.typeParameters; @@ -25702,8 +27609,16 @@ var ts; if (!couldContainTypeParameters(target)) { return; } - if (source.flags & 524288 && target.flags & 524288 && !(source.flags & 16 && target.flags & 16) || - source.flags & 1048576 && target.flags & 1048576) { + if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { + var sourceTypes = source.aliasTypeArguments; + var targetTypes = target.aliasTypeArguments; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + return; + } + if (source.flags & 65536 && target.flags & 65536 && !(source.flags & 16 && target.flags & 16) || + source.flags & 131072 && target.flags & 131072) { if (source === target) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -25731,7 +27646,7 @@ var ts; } } if (target.flags & 16384) { - if (source.flags & 134217728) { + if (source.flags & 8388608) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -25752,7 +27667,7 @@ var ts; } } } - else if (source.flags & 131072 && target.flags & 131072 && source.target === target.target) { + else if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { var sourceTypes = source.typeArguments || emptyArray; var targetTypes = target.typeArguments || emptyArray; var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -25760,7 +27675,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 1572864) { + else if (target.flags & 196608) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter = void 0; @@ -25780,7 +27695,7 @@ var ts; inferiority--; } } - else if (source.flags & 1572864) { + else if (source.flags & 196608) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -25788,8 +27703,21 @@ var ts; } } else { + if (getObjectFlags(target) & 32) { + var constraintType = getConstraintTypeFromMappedType(target); + if (getObjectFlags(source) & 32) { + inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + return; + } + if (constraintType.flags & 16384) { + inferFromTypes(getIndexType(source), constraintType); + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return; + } + } source = getApparentType(source); - if (source.flags & 2588672) { + if (source.flags & 32768) { if (isInProcess(source, target)) { return; } @@ -25818,8 +27746,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)); @@ -25885,7 +27813,7 @@ var ts; reducedTypes.push(t); } } - return type.flags & 524288 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 65536 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function getInferenceCandidates(context, index) { var inferences = context.inferences[index]; @@ -25893,7 +27821,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]; @@ -25946,10 +27874,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: @@ -25966,7 +27894,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 173) { + if (node.kind === 177) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -25977,7 +27905,7 @@ var ts; case 70: case 98: return node; - case 173: + case 177: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -25986,19 +27914,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 || target.kind === 170) && + (target.kind === 223 || target.kind === 174) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 173: - return target.kind === 173 && + case 177: + return target.kind === 177 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173) { + while (source.kind === 177) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26007,7 +27935,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 && + return target.kind === 177 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -26015,14 +27943,14 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173) { + if (expr.kind === 177) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 524288) { + if (type && type.flags & 65536) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456) { if (prop.isDiscriminantProperty === undefined) { @@ -26045,7 +27973,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 && + if (callExpression.expression.kind === 177 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26059,7 +27987,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 524288)) { + if (!(source.flags & 65536)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -26122,7 +28050,7 @@ var ts; type === falseType ? 3030404 : 1981828 : type === falseType ? 3145092 : 4193668; } - if (flags & 2588672) { + if (flags & 32768) { return isFunctionObjectType(type) ? strictNullChecks ? 6164448 : 8376288 : strictNullChecks ? 6166480 : 8378320; @@ -26140,7 +28068,7 @@ var ts; var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); } - if (flags & 1572864) { + if (flags & 196608) { return getTypeFactsOfTypes(type.types); } return 8388607; @@ -26156,7 +28084,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) || @@ -26167,19 +28095,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 === 175 || node.parent.kind === 257 ? 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); @@ -26190,21 +28118,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208: + case 212: return stringType; - case 209: + case 213: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188: - return getAssignedTypeOfBinaryExpression(parent); - case 182: - return undefinedType; - case 171: - return getAssignedTypeOfArrayLiteralElement(parent, node); case 192: - return getAssignedTypeOfSpreadElement(parent); - case 253: + return getAssignedTypeOfBinaryExpression(parent); + case 186: + return undefinedType; + case 175: + return getAssignedTypeOfArrayLiteralElement(parent, node); + case 196: + return getAssignedTypeOfSpreadExpression(parent); + case 257: return getAssignedTypeOfPropertyAssignment(parent); - case 254: + case 258: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -26212,11 +28140,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 ? + var type = pattern.kind === 172 ? 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) { @@ -26227,35 +28155,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 212) { return stringType; } - if (node.parent.parent.kind === 209) { + if (node.parent.parent.kind === 213) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 ? + return node.kind === 223 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 || node.kind === 170 ? + return node.kind === 223 || node.kind === 174 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 && node.initializer && + return node.kind === 223 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 && node.parent.kind === 188 && + node.kind !== 174 && node.parent.kind === 192 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179: + case 183: return getReferenceCandidate(node.expression); - case 188: + case 192: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -26267,13 +28195,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 === 183 || + parent.kind === 192 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 192 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249) { + if (clause.kind === 253) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -26288,13 +28216,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 524288 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 65536 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 524288 && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 65536 && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 524288) { + if (source.flags & 65536) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -26308,8 +28236,11 @@ var ts; } return containsType(target.types, source); } + function forEachType(type, f) { + return type.flags & 65536 ? ts.forEach(type.types, f) : f(type); + } function filterType(type, f) { - if (type.flags & 524288) { + if (type.flags & 65536) { var types = type.types; var filtered = ts.filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered); @@ -26317,7 +28248,7 @@ var ts; return f(type) ? type : neverType; } function mapType(type, f) { - return type.flags & 524288 ? getUnionType(ts.map(type.types, f)) : f(type); + return type.flags & 65536 ? getUnionType(ts.map(type.types, f)) : f(type); } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -26343,7 +28274,7 @@ var ts; return incomplete ? { flags: 0, type: type } : type; } function createEvolvingArrayType(elementType) { - var result = createObjectType(2097152); + var result = createObjectType(256); result.elementType = elementType; return result; } @@ -26354,13 +28285,10 @@ var ts; var elementType = getBaseTypeOfLiteralType(checkExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } - function isEvolvingArrayType(type) { - return !!(type.flags & 2097152 && type.elementType); - } function createFinalArrayType(elementType) { return elementType.flags & 8192 ? autoArrayType : - createArrayType(elementType.flags & 524288 ? + createArrayType(elementType.flags & 65536 ? getUnionType(elementType.types, true) : elementType); } @@ -26368,17 +28296,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return getObjectFlags(type) & 256 ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? type.elementType : neverType; + return getObjectFlags(type) & 256 ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { var t = types_12[_i]; if (!(t.flags & 8192)) { - if (!isEvolvingArrayType(t)) { + if (!(getObjectFlags(t) & 256)) { return false; } hasEvolvingArrayType = true; @@ -26394,20 +28322,40 @@ 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 === 177 && (parent.name.text === "length" || + parent.parent.kind === 179 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 178 && parent.expression === root && - parent.parent.kind === 188 && + parent.parent.kind === 192 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); return isLengthPushOrUnshift || isElementAssignment; } + function maybeTypePredicateCall(node) { + var links = getNodeLinks(node); + if (links.maybeTypePredicate === undefined) { + links.maybeTypePredicate = getMaybeTypePredicate(node); + } + return links.maybeTypePredicate; + } + function getMaybeTypePredicate(node) { + if (node.expression.kind !== 96) { + var funcType = checkNonNullExpression(node.expression); + if (funcType !== silentNeverType) { + var apparentType = getApparentType(funcType); + if (apparentType !== unknownType) { + var callSignatures = getSignaturesOfType(apparentType, 0); + return !!ts.forEach(callSignatures, function (sig) { return sig.typePredicate; }); + } + } + } + return false; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -26416,8 +28364,8 @@ var ts; var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { + var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 201 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -26462,7 +28410,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 !== 177) { flow = container.flowNode; continue; } @@ -26482,7 +28430,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)); } @@ -26493,7 +28441,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 524288) { + if (declaredType.flags & 65536) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -26505,15 +28453,15 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 ? + var expr = node.kind === 179 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (isEvolvingArrayType(type)) { + if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 175) { + if (node.kind === 179) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -26631,8 +28579,8 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 && - declaredType.flags & 524288 && + return expr.kind === 177 && + declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); } @@ -26665,10 +28613,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 === 187 && 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 === 187 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26714,7 +28662,7 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 2589185) { + if (type.flags & 33281) { return type; } if (assumeTrue) { @@ -26738,7 +28686,7 @@ var ts; if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 524288)) { + if (assumeTrue && !(type.flags & 65536)) { var targetType = typeofTypesByName[literal.text]; if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; @@ -26790,10 +28738,10 @@ var ts; } if (!targetType) { var constructSignatures = void 0; - if (rightType.flags & 65536) { + if (getObjectFlags(rightType) & 2) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 2097152) { + else if (getObjectFlags(rightType) & 16) { constructSignatures = getSignaturesOfType(rightType, 1); } if (constructSignatures && constructSignatures.length) { @@ -26809,7 +28757,7 @@ var ts; if (!assumeTrue) { return filterType(type, function (t) { return !isTypeInstanceOf(t, candidate); }); } - if (type.flags & 524288) { + if (type.flags & 65536) { var assignableType = filterType(type, function (t) { return isTypeInstanceOf(t, candidate); }); if (!(assignableType.flags & 8192)) { return assignableType; @@ -26822,7 +28770,7 @@ var ts; getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { return type; } var signature = getResolvedSignature(callExpression); @@ -26845,10 +28793,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 === 178 || invokedExpression.kind === 177) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -26863,15 +28811,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 177: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175: - return narrowTypeByTypePredicate(type, expr, assumeTrue); case 179: + return narrowTypeByTypePredicate(type, expr, assumeTrue); + case 183: return narrowType(type, expr.expression, assumeTrue); - case 188: + case 192: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186: + case 190: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -26894,19 +28842,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 === 231 || + node.kind === 261 || + node.kind === 147) { return node; } } @@ -26937,7 +28879,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; } } @@ -26951,19 +28893,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 === 185) { 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); @@ -26972,7 +28918,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 222 + && declaration_1.kind === 226 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -26984,11 +28930,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193) { + else if (declaration_1.kind === 197) { 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; } @@ -27003,15 +28949,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 === 184 || + flowContainer.kind === 185 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -27032,7 +28989,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; @@ -27047,7 +29004,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 252) { + symbol.valueDeclaration.parent.kind === 256) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27065,8 +29022,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 207 && - ts.getAncestor(symbol.valueDeclaration, 220).parent === container && + if (container.kind === 211 && + ts.getAncestor(symbol.valueDeclaration, 224).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27078,14 +29035,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 179) { + while (current.parent.kind === 183) { 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 === 190 || current.parent.kind === 191)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -27104,7 +29061,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; } @@ -27138,7 +29095,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)) { @@ -27148,29 +29105,29 @@ var ts; } } } - if (container.kind === 181) { + if (container.kind === 185) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 226: + case 230: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 225: + case 229: 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; } @@ -27179,7 +29136,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 180 && + if (container.kind === 184 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27214,27 +29171,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 === 274) { 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 === 277) { 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 === 179 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 181) { + while (container && container.kind === 185) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27243,16 +29200,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 === 176)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27267,7 +29224,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; } @@ -27278,7 +29235,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172) { + if (container.parent.kind === 176) { 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; @@ -27296,7 +29253,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; } @@ -27308,24 +29265,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 === 176) { 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; } } } @@ -27333,7 +29290,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -27389,7 +29346,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; @@ -27400,11 +29357,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_15 = declaration.propertyName || declaration.name; + var name_22 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_15)) { - var text = getTextOfPropertyName(name_15); + !ts.isBindingPattern(name_22)) { + var text = ts.getTextOfPropertyName(name_22); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -27441,7 +29398,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; @@ -27450,8 +29407,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); @@ -27470,7 +29427,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177) { + if (template.parent.kind === 181) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27501,7 +29458,7 @@ var ts; return undefined; } function applyToContextualType(type, mapper) { - if (!(type.flags & 524288)) { + if (!(type.flags & 65536)) { return mapper(type); } var types = type.types; @@ -27526,7 +29483,7 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = t.flags & 4161536 ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 229376 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } @@ -27534,7 +29491,7 @@ var ts; return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 524288 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 65536 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -27578,13 +29535,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246) { + if (attribute.kind === 250) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247) { + else if (attribute.kind === 251) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -27602,56 +29559,70 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219: - case 143: + case 223: + case 144: + case 147: case 146: - case 145: - case 170: + case 174: return getContextualTypeForInitializerExpression(node); - case 181: - case 212: + case 185: + case 216: return getContextualTypeForReturnExpression(node); - case 191: + case 195: 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: + case 180: + return getContextualTypeForArgument(parent, node); + case 182: + case 200: + return getTypeFromTypeNode(parent.type); + case 192: + return getContextualTypeForBinaryOperand(node); + case 257: + case 258: + return getContextualTypeForObjectLiteralElement(parent); + case 175: + return getContextualTypeForElementExpression(node); + case 193: + return getContextualTypeForConditionalOperand(node); + case 202: + ts.Debug.assert(parent.parent.kind === 194); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 183: return getContextualType(parent); - case 248: + case 252: return getContextualType(parent); - case 246: - case 247: + case 250: + case 251: return getContextualTypeForJsxAttribute(parent); } return undefined; } - function getNonGenericSignature(type) { + function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { var signature = signatures[0]; - if (!signature.typeParameters) { + if (!signature.typeParameters && !isAritySmaller(signature, node)) { return signature; } } } + function isAritySmaller(signature, target) { + var targetParameterCount = 0; + for (; targetParameterCount < target.parameters.length; targetParameterCount++) { + var param = target.parameters[targetParameterCount]; + if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { + break; + } + } + if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { + targetParameterCount--; + } + var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; + return sourceLength < targetParameterCount; + } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 || node.kind === 181; + return node.kind === 184 || node.kind === 185; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27664,19 +29635,19 @@ 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; } - if (!(type.flags & 524288)) { - return getNonGenericSignature(type); + if (!(type.flags & 65536)) { + return getNonGenericSignature(type, node); } var signatureList; var types = type.types; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var current = types_14[_i]; - var signature = getNonGenericSignature(current); + var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { signatureList = [signature]; @@ -27700,13 +29671,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 === 174 && !!node.initializer) || + (node.kind === 192 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27715,7 +29686,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 === 196) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27727,7 +29698,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192; + hasSpreadElement = hasSpreadElement || e.kind === 196; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27738,7 +29709,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 === 173 || pattern.kind === 175)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27746,7 +29717,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194) { + if (patternElement.kind !== 198) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27763,7 +29734,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); @@ -27805,9 +29776,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 === 172 || contextualType.pattern.kind === 176); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27815,25 +29788,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 === 257 || + memberDecl.kind === 258 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253) { + if (memberDecl.kind === 257) { 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 === 258); 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 === 257 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 258 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -27841,8 +29814,7 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & 2588672 && contextualType.isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; @@ -27860,8 +29832,25 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 259) { + 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)) { @@ -27889,18 +29878,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 : 16777216; - result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024); - if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + 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 |= 128; + if (patternWithComputedProperties) { + result.objectFlags |= 512; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144)) { + propagatedFlags |= (result.flags & 14680064); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -27917,13 +29921,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248: + case 252: checkJsxExpression(child); break; - case 242: + case 246: checkJsxElement(child); break; - case 243: + case 247: checkJsxSelfClosingElement(child); break; } @@ -27934,7 +29938,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 173 || tagName.kind === 98) { + if (tagName.kind === 177 || tagName.kind === 98) { return false; } else { @@ -27950,7 +29954,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; } @@ -28025,7 +30029,7 @@ var ts; return links.resolvedSymbol; } function getJsxElementInstanceType(node, valueType) { - ts.Debug.assert(!(valueType.flags & 524288)); + ts.Debug.assert(!(valueType.flags & 65536)); if (isTypeAny(valueType)) { return anyType; } @@ -28064,7 +30068,7 @@ var ts; if (!elemType) { elemType = checkExpression(node.tagName); } - if (elemType.flags & 524288) { + if (elemType.flags & 65536) { var types = elemType.types; return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); @@ -28126,7 +30130,7 @@ var ts; else if (isTypeAny(attributesType) || (attributesType === unknownType)) { return attributesType; } - else if (attributesType.flags & 524288) { + else if (attributesType.flags & 65536) { error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; } @@ -28203,20 +30207,23 @@ 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) { - getSymbolLinks(reactSym).referenced = true; + reactSym.isReferenced = true; + if (reactSym.flags & 8388608 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + markAliasSymbolAsReferenced(reactSym); + } } var targetAttributesType = getJsxElementAttributesType(node); 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 === 250) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247); + ts.Debug.assert(node.attributes[i].kind === 251); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -28242,7 +30249,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; @@ -28253,11 +30260,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 === 177 || node.kind === 223 ? 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; } @@ -28294,7 +30301,7 @@ var ts; if (type.flags & 16384 && type.isThisType) { type = getConstraintOfTypeParameter(type); } - if (!(getTargetType(type).flags & (32768 | 65536) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & 3 && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -28320,6 +30327,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) { @@ -28336,44 +30370,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 !== 177 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && - !(prop.flags & 8192 && propType.flags & 524288)) { + !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - return getFlowTypeOfReference(node, propType, true, undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 524288 && !(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 === 177 ? node.expression : node.left; var type = checkExpression(left); @@ -28387,7 +30406,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220) { + if (initializer.kind === 224) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -28402,14 +30421,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 === 212 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28423,9 +30442,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 === 180 && 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); @@ -28435,71 +30456,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) { @@ -28532,10 +30499,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177) { + if (node.kind === 181) { checkExpression(node.template); } - else if (node.kind !== 144) { + else if (node.kind !== 145) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28557,19 +30524,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_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_9; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_9; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -28586,7 +30553,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 === 196) { return i; } } @@ -28599,11 +30566,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177) { + if (node.kind === 181) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190) { + if (tagExpression.template.kind === 194) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28615,7 +30582,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); @@ -28623,7 +30590,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 176); + ts.Debug.assert(callExpression.kind === 180); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28646,7 +30613,7 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & 2588672) { + if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -28682,7 +30649,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 !== 198) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -28729,7 +30696,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 !== 180) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28742,7 +30709,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 !== 198) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -28757,28 +30724,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 175) { + if (node.kind === 179) { var callee = node.expression; - if (callee.kind === 173) { + if (callee.kind === 177) { return callee.expression; } - else if (callee.kind === 174) { + else if (callee.kind === 178) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 177) { + if (node.kind === 181) { var template = node.template; args = [undefined]; - if (template.kind === 190) { + if (template.kind === 194) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144) { + else if (node.kind === 145) { return undefined; } else { @@ -28787,21 +30754,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 226: + case 197: 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; } } @@ -28810,48 +30777,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 226) { 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 === 226) { 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; @@ -28868,20 +30835,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 226) { 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); } @@ -28902,26 +30869,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 === 181) { 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 === 181)) { 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 === 181) { return node.template; } else { @@ -28929,8 +30896,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177; - var isDecorator = node.kind === 144; + var isTaggedTemplate = node.kind === 181; + var isDecorator = node.kind === 145; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -28960,7 +30927,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 179 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -28979,7 +30946,7 @@ var ts; else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { var typeArguments_2 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNodeNoAlias), true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -29000,7 +30967,7 @@ var ts; var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNodeNoAlias)); + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); } return candidate; } @@ -29032,7 +30999,7 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNodeNoAlias); + typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); } else { @@ -29121,7 +31088,7 @@ var ts; return true; } if (!numCallSignatures && !numConstructSignatures) { - if (funcType.flags & 524288) { + if (funcType.flags & 65536) { return false; } return isTypeAssignableTo(funcType, globalFunctionType); @@ -29228,16 +31195,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222: - case 193: + case 226: + case 197: 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; } } @@ -29264,13 +31231,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175: + case 179: return resolveCallExpression(node, candidatesOutArray); - case 176: + case 180: return resolveNewExpression(node, candidatesOutArray); - case 177: + case 181: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144: + case 145: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29302,12 +31269,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 176) { + if (node.kind === 180) { 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) : @@ -29321,13 +31288,33 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && - ts.isRequireCall(node, true) && - !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { + if (ts.isInJavaScriptFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); } + function isCommonJsRequire(node) { + if (!ts.isRequireCall(node, true)) { + return false; + } + var resolvedRequire = resolveName(node.expression, node.expression.text, 107455, undefined, undefined); + if (!resolvedRequire) { + return true; + } + if (resolvedRequire.flags & 8388608) { + return false; + } + var targetDeclarationKind = resolvedRequire.flags & 16 + ? 225 + : resolvedRequire.flags & 3 + ? 223 + : 0; + if (targetDeclarationKind !== 0) { + var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + return ts.isInAmbientContext(decl); + } + return false; + } function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } @@ -29413,8 +31400,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 === 172 || + parameter.valueDeclaration.name.kind === 173)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29441,7 +31428,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; @@ -29453,7 +31440,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200) { + if (func.body.kind !== 204) { 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); @@ -29532,7 +31519,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 218 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29561,7 +31548,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 || func.kind === 181)) { + func.kind === 184 || func.kind === 185)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29578,7 +31565,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 !== 204 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29605,9 +31592,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 === 184) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29641,14 +31628,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) { @@ -29658,7 +31645,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200) { + if (node.body.kind === 204) { checkSourceElement(node.body); } else { @@ -29693,10 +31680,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 173 || expr.kind === 174) && + (expr.kind === 177 || expr.kind === 178) && 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); } @@ -29705,44 +31692,24 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 || expr.kind === 174) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 177 || expr.kind === 178) { + 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 === 237; } } } 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 !== 177 && node.kind !== 178) { 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) { @@ -29759,7 +31726,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)) { @@ -29794,7 +31761,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; } @@ -29807,7 +31774,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; } @@ -29815,7 +31782,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 1572864) { + if (type.flags & 196608) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -29830,7 +31797,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 524288) { + if (type.flags & 65536) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -29840,7 +31807,7 @@ var ts; } return true; } - if (type.flags & 1048576) { + if (type.flags & 131072) { var types = type.types; for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { var t = types_17[_a]; @@ -29852,7 +31819,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (2588672 | 2097152) && type.symbol && isConstEnumSymbol(type.symbol); + return getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; @@ -29876,36 +31843,36 @@ var ts; if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 | 340 | 512)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } 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 === 257 || property.kind === 258) { + var name_23 = property.name; + if (name_23.kind === 142) { + checkComputedPropertyName(name_23); } - if (isComputedNonLiteralName(name_17)) { + if (isComputedNonLiteralName(name_23)) { return undefined; } - var text = getTextOfPropertyName(name_17); + 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 === 258) { return checkDestructuringAssignment(property, type); } else { @@ -29913,7 +31880,12 @@ 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_23, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_23)); + } + } + else if (property.kind === 259) { + if (property.expression.kind !== 70) { + error(property.expression, ts.Diagnostics.An_object_rest_element_must_be_an_identifier); } } else { @@ -29931,8 +31903,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 !== 198) { + if (element.kind !== 196) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -29954,11 +31926,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 === 192 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -29971,7 +31943,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254) { + if (exprOrAssignment.kind === 258) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -29985,21 +31957,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 && target.operatorToken.kind === 57) { + if (target.kind === 192 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172) { + if (target.kind === 176) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171) { + if (target.kind === 175) { 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; @@ -30010,35 +31982,35 @@ var ts; case 70: case 9: case 11: - case 177: - case 190: + case 181: + case 194: case 12: case 8: case 100: case 85: case 94: - case 136: - case 180: - case 193: - case 181: - case 171: - case 172: - case 183: + case 137: + case 184: case 197: - case 243: - case 242: + case 185: + case 175: + case 176: + case 187: + case 201: + case 247: + case 246: return true; - case 189: + case 193: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188: + case 192: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186: - case 187: + case 190: + case 191: switch (node.operator) { case 50: case 36: @@ -30047,9 +32019,9 @@ var ts; return true; } return false; - case 184: - case 178: - case 196: + case 188: + case 182: + case 200: default: return false; } @@ -30069,7 +32041,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 === 176 || left.kind === 175)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -30226,8 +32198,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); } } @@ -30253,7 +32224,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)) { @@ -30327,8 +32298,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 === 182 || node.kind === 200; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30354,14 +32325,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); @@ -30384,7 +32355,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140) { + if (node.kind === 141) { type = checkQualifiedName(node); } else { @@ -30392,9 +32363,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 === 177 && node.parent.expression === node) || + (node.parent.kind === 178 && 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); } @@ -30416,66 +32387,66 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 190: + case 194: 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); case 175: + return checkArrayLiteral(node, contextualMapper); case 176: - return checkCallExpression(node); + return checkObjectLiteral(node, contextualMapper); 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 checkPropertyAccessExpression(node); case 178: - case 196: - return checkAssertion(node); + return checkIndexedAccess(node); + case 179: + case 180: + return checkCallExpression(node); + case 181: + return checkTaggedTemplateExpression(node); + case 183: + return checkExpression(node.expression, contextualMapper); case 197: - return checkNonNullAssertion(node); - case 182: - return checkDeleteExpression(node); + return checkClassExpression(node); case 184: - return checkVoidExpression(node); case 185: - return checkAwaitExpression(node); - case 186: - return checkPrefixUnaryExpression(node); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 187: - return checkPostfixUnaryExpression(node); + return checkTypeOfExpression(node); + case 182: + case 200: + return checkAssertion(node); + case 201: + return checkNonNullAssertion(node); + case 186: + return checkDeleteExpression(node); case 188: - return checkBinaryExpression(node, contextualMapper); + return checkVoidExpression(node); case 189: - return checkConditionalExpression(node, contextualMapper); - case 192: - return checkSpreadElementExpression(node, contextualMapper); - case 194: - return undefinedWideningType; + return checkAwaitExpression(node); + case 190: + return checkPrefixUnaryExpression(node); case 191: + return checkPostfixUnaryExpression(node); + case 192: + return checkBinaryExpression(node, contextualMapper); + case 193: + return checkConditionalExpression(node, contextualMapper); + case 196: + return checkSpreadExpression(node, contextualMapper); + case 198: + return undefinedWideningType; + case 195: return checkYieldExpression(node); - case 248: + case 252: return checkJsxExpression(node); - case 242: + case 246: return checkJsxElement(node); - case 243: + case 247: return checkJsxSelfClosingElement(node); - case 244: + case 248: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30496,7 +32467,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); } } @@ -30507,7 +32478,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); } } @@ -30519,9 +32490,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 === 225 || + node.kind === 184; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -30562,9 +32533,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_24 = _a[_i].name; + if (ts.isBindingPattern(name_24) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -30577,16 +32548,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181: - case 152: - case 221: - case 180: - case 157: + case 185: + case 153: + case 225: + case 184: + case 158: + case 149: case 148: - case 147: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -30596,27 +32567,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_19 = element.name; - if (name_19.kind === 70 && - name_19.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_19.kind === 169 || - name_19.kind === 168) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { + else if (name_25.kind === 173 || + name_25.kind === 172) { + 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 === 225 || node.kind === 159 || + node.kind === 153 || node.kind === 150 || + node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30628,10 +32599,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; } @@ -30658,17 +32629,11 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { - var Accessor; - (function (Accessor) { - Accessor[Accessor["Getter"] = 1] = "Getter"; - Accessor[Accessor["Setter"] = 2] = "Setter"; - Accessor[Accessor["Property"] = 3] = "Property"; - })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); 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)) { @@ -30682,13 +32647,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; } @@ -30714,7 +32679,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: @@ -30736,7 +32701,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223) { + if (node.kind === 227) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30751,7 +32716,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; } @@ -30759,7 +32724,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131: + case 132: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30818,12 +32783,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 !== 184 && n.kind !== 225) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 && + return n.kind === 147 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30843,7 +32808,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 === 207 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -30866,18 +32831,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)) { @@ -30891,11 +32856,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 !== 176) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -30925,7 +32890,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -30976,14 +32941,25 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } + function checkMappedType(node) { + checkSourceElement(node.typeParameter); + checkSourceElement(node.type); + var type = getTypeFromMappedTypeNode(node); + var constraintType = getConstraintTypeFromMappedType(type); + var keyType = constraintType.flags & 16384 ? getApparentTypeOfTypeParameter(constraintType) : constraintType; + checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint); + } 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 !== 227 && + n.parent.kind !== 226 && + n.parent.kind !== 197 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31060,7 +33036,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; @@ -31093,11 +33069,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 === 227 || 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 === 225 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31208,16 +33184,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223: + case 227: return 2097152; - case 226: + case 230: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 222: - case 225: + case 226: + case 229: return 2097152 | 1048576; - case 230: + case 234: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31244,7 +33220,7 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (promise.flags & 131072) { + if (getObjectFlags(promise) & 4) { if (promise.target === tryGetGlobalPromiseType() || promise.target === getGlobalPromiseLikeType()) { return promise.typeArguments[0]; @@ -31281,7 +33257,7 @@ var ts; function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); function checkAwaitedTypeWorker(type) { - if (type.flags & 524288) { + if (type.flags & 65536) { var types = []; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -31309,51 +33285,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); @@ -31365,22 +33340,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222: + case 226: 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]); @@ -31388,29 +33363,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) { @@ -31425,21 +33386,27 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 222: + case 226: 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; } } @@ -31458,7 +33425,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)) { @@ -31500,43 +33467,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 261: + case 230: checkUnusedModuleMembers(node); break; - case 222: - case 193: + case 226: + case 197: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223: + case 227: checkUnusedTypeParameters(node); break; - case 200: - case 228: - case 207: - case 208: - case 209: + case 204: + case 232: + case 211: + case 212: + case 213: checkUnusedLocalsAndParameters(node); break; - case 149: - case 180: - case 221: - case 181: - case 148: case 150: + case 184: + case 225: + case 185: + 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; } @@ -31545,43 +33512,57 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_1 = function (key) { + if (node.parent.kind !== 227 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 143) { - var parameter = local.valueDeclaration; + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { + var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { + !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return error(d.name || d, ts.Diagnostics._0_is_declared_but_never_used, local.name); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } }; for (var key in node.locals) { - _loop_1(key); + _loop_3(key); } } } - function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; + function errorUnusedLocal(node, name) { + if (isIdentifierThatStartsWithUnderScore(node)) { + var declaration = ts.getRootDeclaration(node.parent); + if (declaration.kind === 223 && + (declaration.parent.parent.kind === 212 || + declaration.parent.parent.kind === 213)) { + return; + } + } + error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + } + function parameterNameStartsWithUnderscore(parameterName) { + return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); + } + function isIdentifierThatStartsWithUnderScore(node) { + return node.kind === 70 && node.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { 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) { @@ -31626,7 +33607,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 200) { + if (node.kind === 204) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31648,19 +33629,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; @@ -31711,11 +33692,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 261 && 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)); } } @@ -31723,11 +33704,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 261 && 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)); } } @@ -31735,7 +33716,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 219 && !node.initializer) { + if (node.kind === 223 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31745,25 +33726,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, 224); + var container = varDeclList.parent.kind === 205 && 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 === 204 && ts.isFunctionLike(container.parent) || + container.kind === 231 || + container.kind === 230 || + container.kind === 261); 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_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); @@ -31772,7 +33753,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 173) { + if (n.kind === 177) { return visit(n.expression); } else if (n.kind === 70) { @@ -31786,7 +33767,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; } @@ -31795,7 +33776,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; @@ -31817,33 +33798,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 === 174) { + 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_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); + var name_27 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_27)); + markPropertyAsReferenced(property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.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 !== 212) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31852,7 +33834,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 !== 212) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -31870,9 +33852,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 === 223 || node.kind === 174) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -31882,8 +33864,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 === 223) || + (left.kind === 223 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -31910,7 +33892,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 === 176) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -31929,7 +33911,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202) { + if (node.thenStatement.kind === 206) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -31946,12 +33928,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220) { + if (node.initializer && node.initializer.kind === 224) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -31969,18 +33951,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 175 || varExpr.kind === 176) { 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); } @@ -31993,7 +33975,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 224) { 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); @@ -32003,18 +33985,18 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 175 || varExpr.kind === 176) { 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); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -32067,7 +34049,7 @@ var ts; } var typeAsIterable = type; if (!typeAsIterable.iterableElementType) { - if ((type.flags & 131072) && type.target === getGlobalIterableType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableType()) { typeAsIterable.iterableElementType = type.typeArguments[0]; } else { @@ -32093,7 +34075,7 @@ var ts; } var typeAsIterator = type; if (!typeAsIterator.iteratorElementType) { - if ((type.flags & 131072) && type.target === getGlobalIteratorType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIteratorType()) { typeAsIterator.iteratorElementType = type.typeArguments[0]; } else { @@ -32128,7 +34110,7 @@ var ts; if (isTypeAny(type)) { return undefined; } - if ((type.flags & 131072) && type.target === getGlobalIterableIteratorType()) { + if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableIteratorType()) { return type.typeArguments[0]; } return getElementTypeOfIterable(type, undefined) || @@ -32137,8 +34119,12 @@ var ts; function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { ts.Debug.assert(languageVersion < 2); var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 524288) { - arrayType = getUnionType(ts.filter(arrayOrStringType.types, function (t) { return !(t.flags & 34); }), true); + if (arrayOrStringType.flags & 65536) { + var arrayTypes = arrayOrStringType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, true); + } } else if (arrayOrStringType.flags & 34) { arrayType = neverType; @@ -32176,7 +34162,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; @@ -32198,12 +34184,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); } @@ -32221,14 +34207,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); } } @@ -32245,8 +34231,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 === 254 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -32258,11 +34245,17 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249) { + if (produceDiagnostics && clause.kind === 253) { 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); @@ -32278,7 +34271,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 && current.label.text === node.label.text) { + if (current.kind === 219 && 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; @@ -32304,22 +34297,20 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 70) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { + if (catchClause.variableDeclaration.type) { grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); } else if (catchClause.variableDeclaration.initializer) { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + var blockLocals = catchClause.block.locals; + if (blockLocals) { + for (var caughtName in catchClause.locals) { + var blockLocal = blockLocals[caughtName]; + if (blockLocal && (blockLocal.flags & 2) !== 0) { + grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); + } } } } @@ -32341,7 +34332,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (type.flags & 32768 && ts.isClassLike(type.symbol.valueDeclaration)) { + if (getObjectFlags(type) & 1 && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -32356,7 +34347,7 @@ var ts; var errorNode; if (stringIndexType && numberIndexType) { errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 65536)) { + if (!errorNode && (getObjectFlags(type) & 2)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } @@ -32372,13 +34363,13 @@ 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) { errorNode = indexDeclaration; } - else if (containingType.flags & 65536) { + else if (getObjectFlags(containingType) & 2) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; } @@ -32423,7 +34414,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 === 226 || declaration.kind === 227) { if (!firstDecl) { firstDecl = declaration; } @@ -32486,7 +34477,9 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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)) { + if (baseType_1.symbol.valueDeclaration && + !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && + baseType_1.symbol.valueDeclaration.kind === 226) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -32511,8 +34504,8 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = (t.flags & 131072) ? t.target : t; - if (declaredType.flags & (32768 | 65536)) { + var declaredType = getObjectFlags(t) & 4 ? t.target : t; + if (getObjectFlags(declaredType) & 3) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -32534,7 +34527,7 @@ var ts; if (declaration && ts.getModifierFlags(declaration) & 8) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { - error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); } } } @@ -32560,7 +34553,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 === 197) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32604,7 +34597,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 || kind === 151; + return kind === 151 || kind === 152; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32642,8 +34635,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 }; @@ -32671,7 +34664,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 227); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32700,6 +34693,7 @@ var ts; function checkTypeAliasDeclaration(node) { checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } function computeEnumMemberValues(node) { @@ -32716,7 +34710,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); } @@ -32766,7 +34760,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186: + case 190: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -32777,7 +34771,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 188: + case 192: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32802,11 +34796,11 @@ var ts; return undefined; case 8: return +e.text; - case 179: + case 183: return evalConstant(e.expression); case 70: - case 174: - case 173: + case 178: + case 177: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -32817,7 +34811,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174) { + if (e.kind === 178) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32834,7 +34828,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 173) { + else if (current.kind === 177) { current = current.expression; } else { @@ -32894,7 +34888,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 225) { + if (declaration.kind !== 229) { return false; } var enumDeclaration = declaration; @@ -32917,8 +34911,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 === 226 || + (declaration.kind === 225 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -32977,7 +34971,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, 226); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33020,36 +35014,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201: + case 205: 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 240: + case 241: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230: - case 231: + case 234: + case 235: 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 174: + case 223: + 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 224: + case 229: + case 225: + case 227: + case 230: + case 228: if (isGlobalAugmentation) { return; } @@ -33067,12 +35061,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 177: do { node = node.expression; } while (node.kind !== 70); @@ -33085,9 +35079,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 === 231 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 && !inAmbientExternalModule) { + error(moduleName, node.kind === 241 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33108,7 +35102,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 === 243 ? 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)); @@ -33135,7 +35129,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 237) { checkImportBinding(importClause.namedBindings); } else { @@ -33186,8 +35180,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 === 231 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -33200,7 +35194,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 === 261 || node.parent.kind === 231 || node.parent.kind === 230; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33223,8 +35217,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 === 261 ? node.parent : node.parent.parent; + if (container.kind === 230 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -33291,7 +35285,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 && declaration.kind !== 148) || + return (declaration.kind !== 225 && declaration.kind !== 149) || !!declaration.body; } } @@ -33302,118 +35296,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 230: case 226: - case 222: - case 223: - case 221: + case 227: + case 225: 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 169: + return checkIndexedAccessType(node); case 170: - return checkBindingElement(node); - case 222: - return checkClassDeclaration(node); - case 223: - return checkInterfaceDeclaration(node); - case 224: - return checkTypeAliasDeclaration(node); + return checkMappedType(node); case 225: - return checkEnumDeclaration(node); - case 226: - return checkModuleDeclaration(node); + return checkFunctionDeclaration(node); + case 204: case 231: - return checkImportDeclaration(node); - case 230: - return checkImportEqualsDeclaration(node); - case 237: - return checkExportDeclaration(node); - case 236: - return checkExportAssignment(node); - case 202: - checkGrammarStatementInAmbientContext(node); - return; + return checkBlock(node); + case 205: + return checkVariableStatement(node); + case 207: + return checkExpressionStatement(node); + case 208: + return checkIfStatement(node); + case 209: + return checkDoStatement(node); + case 210: + return checkWhileStatement(node); + case 211: + return checkForStatement(node); + case 212: + return checkForInStatement(node); + case 213: + return checkForOfStatement(node); + case 214: + case 215: + return checkBreakOrContinueStatement(node); + case 216: + return checkReturnStatement(node); + case 217: + return checkWithStatement(node); case 218: + return checkSwitchStatement(node); + case 219: + return checkLabeledStatement(node); + case 220: + return checkThrowStatement(node); + case 221: + return checkTryStatement(node); + case 223: + return checkVariableDeclaration(node); + case 174: + return checkBindingElement(node); + case 226: + return checkClassDeclaration(node); + case 227: + return checkInterfaceDeclaration(node); + case 228: + return checkTypeAliasDeclaration(node); + case 229: + return checkEnumDeclaration(node); + case 230: + return checkModuleDeclaration(node); + case 235: + return checkImportDeclaration(node); + case 234: + return checkImportEqualsDeclaration(node); + case 241: + return checkExportDeclaration(node); + case 240: + return checkExportAssignment(node); + case 206: checkGrammarStatementInAmbientContext(node); return; - case 240: + case 222: + checkGrammarStatementInAmbientContext(node); + return; + case 244: return checkMissingDeclaration(node); } } @@ -33426,17 +35425,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 184: + case 185: + case 149: case 148: - case 147: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150: case 151: + case 152: checkAccessorDeferred(node); break; - case 193: + case 197: checkClassExpressionDeferred(node); break; } @@ -33490,8 +35489,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(); @@ -33508,7 +35518,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 && node.parent.statement === node) { + if (node.parent.kind === 217 && node.parent.statement === node) { return true; } node = node.parent; @@ -33530,28 +35540,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256: + case 261: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226: + case 230: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 225: + case 229: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 193: + case 197: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 222: - case 223: + case 226: + case 227: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 180: + case 184: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33590,27 +35600,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142: - case 222: - case 223: - case 224: - case 225: + case 143: + case 226: + case 227: + case 228: + case 229: 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 === 272); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173) { + while (node.parent && node.parent.kind === 177) { node = node.parent; } - return node.parent && node.parent.kind === 195; + return node.parent && node.parent.kind === 199; } function forEachEnclosingClass(node, callback) { var result; @@ -33627,13 +35637,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 === 234) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 240) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33645,7 +35655,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 === 177) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33657,11 +35667,11 @@ var ts; default: } } - if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 240 && 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 !== 177 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 234); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -33670,7 +35680,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 195) { + if (entityName.parent.kind === 199) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33692,14 +35702,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 173) { + else if (entityName.kind === 177) { 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); @@ -33708,19 +35718,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 === 272) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 246) { + else if (entityName.parent.kind === 250) { 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 === 261) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -33736,8 +35746,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 === 174 && + node.parent.parent.kind === 172 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33748,8 +35758,8 @@ var ts; } switch (node.kind) { case 70: - case 173: - case 140: + case 177: + case 141: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -33762,18 +35772,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 === 235 || node.parent.kind === 241) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33781,7 +35791,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 174 && node.parent.argumentExpression === node) { + if (node.parent.kind === 178 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33795,7 +35805,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 254) { + if (location && location.kind === 258) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -33845,20 +35855,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 === 176 || expr.kind === 175); + if (expr.parent.kind === 213) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 188) { + if (expr.parent.kind === 192) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 253) { + if (expr.parent.kind === 257) { 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 === 175); 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); @@ -33894,9 +35904,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_23 = symbol.name; + var name_29 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_23); + var symbol = getPropertyOfType(t, name_29); if (symbol) { symbols_3.push(symbol); } @@ -33904,6 +35914,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) { @@ -33961,7 +35975,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 261) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -33999,7 +36013,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 === 204 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34039,16 +36053,16 @@ var ts; return true; } switch (node.kind) { - case 230: - case 232: - case 233: - case 235: - case 239: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 234: + case 236: case 237: + case 239: + case 243: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 241: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236: + case 240: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -34058,7 +36072,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 !== 261 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -34109,7 +36123,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255) { + if (node.kind === 260) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -34121,7 +36135,7 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 2588672 && getSignaturesOfType(type, 0).length > 0; + return type.flags & 32768 && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); @@ -34203,9 +36217,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_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -34225,7 +36239,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 16777216); + return !!(type.flags & 96 && type.flags & 1048576); } return false; } @@ -34276,13 +36290,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 === 177) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34304,6 +36319,9 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + return undefined; + } } } return typeReferenceDirectives; @@ -34314,15 +36332,15 @@ var ts; } var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 261 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -34341,7 +36359,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256); + return ts.getDeclarationOfKind(moduleSymbol, 261); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -34371,7 +36389,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) { @@ -34440,9 +36458,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) { @@ -34477,7 +36499,7 @@ var ts; function createThenableType() { var thenPropertySymbol = createSymbol(67108864 | 4, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(2097152); + var thenableType = createObjectType(16); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; @@ -34489,14 +36511,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); @@ -34513,17 +36535,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 !== 229 && node.parent.kind === 226) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -34549,7 +36571,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 === 231 || node.parent.kind === 261) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -34572,10 +36594,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 === 231 || node.parent.kind === 261) { 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) { @@ -34584,11 +36606,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; @@ -34607,10 +36629,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 === 226) { 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; @@ -34622,13 +36644,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 === 226) { 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 === 231) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -34638,14 +36660,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 !== 226) { + 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 === 226 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34664,7 +36686,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; @@ -34672,7 +36694,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"); } @@ -34687,13 +36709,13 @@ var ts; } return; } - else if ((node.kind === 231 || node.kind === 230) && flags & 2) { + else if ((node.kind === 235 || node.kind === 234) && 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) { @@ -34709,37 +36731,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 146: + case 149: + case 148: + case 155: case 230: - case 237: - case 236: - case 180: - case 181: - case 143: + case 235: + case 234: + case 241: + case 240: + case 184: + case 185: + case 144: return false; default: - if (node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 231 || node.parent.kind === 261) { 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; case 225: + return nodeHasAnyModifiersExcept(node, 119); + case 226: + return nodeHasAnyModifiersExcept(node, 116); + case 227: + case 205: + case 228: + return true; + case 229: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -34752,10 +36774,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148: - case 221: - case 180: - case 181: + case 149: + case 225: + case 184: + case 185: if (!node.asteriskToken) { return false; } @@ -34817,7 +36839,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181) { + if (node.kind === 185) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34852,7 +36874,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) { @@ -34879,7 +36901,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 === 198) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -34949,19 +36971,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 === 192 && 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 === 225 || + node.kind === 184 || + node.kind === 149); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -34986,42 +37008,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 === 259) { + continue; } - if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { + var name_30 = prop.name; + if (name_30.kind === 142) { + checkGrammarComputedPropertyName(name_30); + } + if (prop.kind === 258 && !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 === 257 || prop.kind === 258) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_24.kind === 8) { - checkGrammarNumericLiteral(name_24); + 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_24); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); if (effectiveName === undefined) { continue; } @@ -35031,18 +37056,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_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_24, 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_24, 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); } } } @@ -35051,19 +37076,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 === 251) { continue; } var jsxAttr = attr; - var name_25 = jsxAttr.name; - if (!seen[name_25.text]) { - seen[name_25.text] = true; + var name_31 = jsxAttr.name; + if (!seen[name_31.text]) { + seen[name_31.text] = true; } else { - return grammarErrorOnNode(name_25, 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 === 252 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -35072,7 +37097,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220) { + if (forInOrOfStatement.initializer.kind === 224) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35080,20 +37105,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 + var diagnostic = forInOrOfStatement.kind === 212 ? 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 === 212 ? 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 === 212 ? 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); @@ -35117,11 +37142,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); } @@ -35140,10 +37165,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); } } @@ -35158,7 +37183,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172) { + if (node.parent.kind === 176) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -35174,10 +37199,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 === 227) { 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); } } @@ -35188,9 +37213,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215: + case 219: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 210 + var isMisplacedContinueLabel = node.kind === 214 && !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); @@ -35198,8 +37223,8 @@ var ts; return false; } break; - case 214: - if (node.kind === 211 && !node.label) { + case 218: + if (node.kind === 215 && !node.label) { return false; } break; @@ -35212,13 +37237,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 + var message = node.kind === 215 ? 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 === 215 ? 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); @@ -35228,9 +37253,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 === 173 || node.name.kind === 172) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35240,11 +37265,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 190 && 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 !== 212 && node.parent.parent.kind !== 213) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35301,15 +37326,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204: - case 205: - case 206: - case 213: - case 207: case 208: case 209: + case 210: + case 217: + case 211: + case 212: + case 213: return false; - case 215: + case 219: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35364,7 +37389,7 @@ var ts; return true; } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 227) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35372,7 +37397,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; } @@ -35385,13 +37410,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 === 227 || + node.kind === 228 || + node.kind === 235 || + node.kind === 234 || + node.kind === 241 || + node.kind === 240 || + node.kind === 233 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35400,7 +37425,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 === 205) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35419,7 +37444,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 === 204 || node.parent.kind === 231 || node.parent.kind === 261) { 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); @@ -35458,49 +37483,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[182] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196] = [ + _a[200] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197] = [ + _a[201] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225] = [ + _a[229] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227] = [ + _a[231] = [ { name: "statements", test: ts.isStatement } ], - _a[230] = [ + _a[234] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241] = [ + _a[245] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255] = [ + _a[260] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -35513,41 +37538,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 <= 171)) { return initial; } var result = initial; switch (node.kind) { - case 199: - case 202: - case 194: - case 218: - case 287: + case 203: + case 206: + case 198: + case 222: + case 292: 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); @@ -35556,17 +37581,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: @@ -35574,46 +37591,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 172: + case 173: result = ts.reduceLeft(node.elements, f, result); break; - case 170: + case 174: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 171: + case 175: result = ts.reduceLeft(node.elements, f, result); break; - case 172: + case 176: result = ts.reduceLeft(node.properties, f, result); break; - case 173: + case 177: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174: + case 178: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175: + case 179: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176: + case 180: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177: + case 181: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180: + case 184: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35621,117 +37646,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181: + case 185: 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 189: + case 195: + case 196: + case 201: + result = reduceNode(node.expression, f, result); + break; + case 190: + case 191: result = reduceNode(node.operand, f, result); break; - case 188: + case 192: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189: + case 193: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190: + case 194: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193: + case 197: 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 199: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 198: + case 202: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 200: + case 204: result = ts.reduceLeft(node.statements, f, result); break; - case 201: + case 205: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203: + case 207: result = reduceNode(node.expression, f, result); break; - case 204: + case 208: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205: + case 209: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206: - case 213: + case 210: + case 217: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207: + case 211: 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 212: + case 213: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212: case 216: + case 220: result = reduceNode(node.expression, f, result); break; - case 214: + case 218: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215: + case 219: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217: + case 221: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219: + case 223: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220: + case 224: result = ts.reduceLeft(node.declarations, f, result); break; - case 221: + case 225: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35740,7 +37765,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222: + case 226: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35748,89 +37773,92 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228: + case 232: result = ts.reduceLeft(node.clauses, f, result); break; - case 231: + case 235: 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 236: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233: + case 237: result = reduceNode(node.name, f, result); break; - case 234: case 238: + case 242: result = ts.reduceLeft(node.elements, f, result); break; - case 235: case 239: + case 243: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236: + case 240: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237: + case 241: 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 246: 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 247: + case 248: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245: + case 249: result = reduceNode(node.tagName, f, result); break; - case 246: + case 250: 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); - 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); + break; + case 253: + result = reduceNode(node.expression, f, result); + case 254: + result = ts.reduceLeft(node.statements, f, result); + break; + case 255: + result = ts.reduceLeft(node.types, f, result); + break; + case 256: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; - case 253: + case 257: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254: + case 258: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; - case 256: + case 259: + result = reduceNode(node.expression, f, result); + break; + case 261: result = ts.reduceLeft(node.statements, f, result); break; - case 288: + case 293: result = reduceNode(node.expression, f, result); break; default: @@ -35855,6 +37883,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -35897,6 +37926,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) { @@ -35933,178 +37963,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 <= 171)) { 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 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())); + case 198: case 222: + 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 172: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 173: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 174: + 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 175: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 176: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 177: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 178: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 179: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 180: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 181: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 183: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 184: + 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 185: + 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 186: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 187: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 189: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 192: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 190: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 191: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 193: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 194: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 195: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 196: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 197: + 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 199: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 204: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 205: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 207: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 208: + 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 209: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 210: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 211: + 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 212: + 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 213: + 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 214: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 215: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 216: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 217: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 218: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 219: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 220: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 221: + 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 223: + 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 224: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 225: + 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 226: 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)); - case 234: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 235: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + 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 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.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); 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.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 238: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 239: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + case 240: + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 241: + 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 242: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); 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)); - case 245: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 246: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 247: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSelfClosingElement(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.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 249: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 250: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 251: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxSpreadAttribute(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.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 253: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), 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.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 255: + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); case 256: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 257: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 258: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 259: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 261: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 288: + case 293: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -36163,7 +38195,7 @@ var ts; return 0; } else if (node.transformFlags & 536870912) { - return node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); + return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind); } else { var subtreeFlags = aggregateTransformFlagsForSubtree(node); @@ -36179,68 +38211,17 @@ var ts; function aggregateTransformFlagsForChildNode(transformFlags, child) { return transformFlags | aggregateTransformFlagsForNode(child); } - function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 && kind <= 167) { - 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 150: - 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: - case 153: - case 154: - case 223: - case 224: - return -3; - case 172: - return 539110741; - default: - return 536874325; - } - } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function () { }; + : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function () { }; + : ts.noop; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function () { }; + : ts.noop; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36259,7 +38240,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)) { @@ -36278,7 +38259,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); } @@ -36296,11 +38277,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); @@ -36313,12 +38297,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) { @@ -36348,33 +38335,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); } @@ -36405,17 +38398,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172) { + if (target.kind === 176) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171) { + else if (target.kind === 175) { 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_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) { @@ -36423,16 +38416,79 @@ 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 === 257 || p.kind === 258) { + if (!transformRest || + p.transformFlags & 8388608 || + (p.kind === 257 && p.initializer.transformFlags & 8388608)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 258 ? p : p.initializer || propName; + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && + p.kind === 259 && + 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 === 198) { + 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) { @@ -36440,8 +38496,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 !== 198) { + if (e.kind !== 196) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36450,42 +38506,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 === 173) { + 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) { @@ -36528,12 +38672,6 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; - var TypeScriptSubstitutionFlags; - (function (TypeScriptSubstitutionFlags) { - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; - })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36544,14 +38682,14 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(174); + context.enableSubstitution(177); + context.enableSubstitution(178); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -36577,7 +38715,7 @@ var ts; return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 256) { + if (node.kind === 261) { return visitSourceFile(node); } else if (node.transformFlags & 1) { @@ -36593,13 +38731,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231: + case 235: return visitImportDeclaration(node); - case 230: + case 234: return visitImportEqualsDeclaration(node); - case 236: + case 240: return visitExportAssignment(node); - case 237: + case 241: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -36609,11 +38747,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 === 241 || + node.kind === 235 || + node.kind === 236 || + (node.kind === 234 && + node.moduleReference.kind === 245)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36629,21 +38767,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 203: 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); @@ -36658,78 +38805,81 @@ 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 171: + case 155: + case 145: + case 228: + 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 227: + return ts.createNotEmittedStatement(node); case 226: - return visitModuleDeclaration(node); + return visitClassDeclaration(node); + case 197: + return visitClassExpression(node); + case 255: + return visitHeritageClause(node); + case 199: + return visitExpressionWithTypeArguments(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessor(node); + case 152: + return visitSetAccessor(node); + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 183: + return visitParenthesizedExpression(node); + case 182: + case 200: + return visitAssertionExpression(node); + case 179: + return visitCallExpression(node); + case 180: + return visitNewExpression(node); + case 201: + return visitNonNullExpression(node); + case 229: + return visitEnumDeclaration(node); + case 205: + return visitVariableStatement(node); + case 223: + return visitVariableDeclaration(node); case 230: + return visitModuleDeclaration(node); + case 234: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36738,15 +38888,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 256: - case 228: - case 227: - case 200: + case 261: + case 232: + case 231: + case 204: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222: - case 221: + case 226: + case 225: if (ts.hasModifier(node, 2)) { break; } @@ -36756,10 +38906,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(); @@ -36770,10 +38921,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; } @@ -36800,66 +38951,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); @@ -36892,7 +39036,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); @@ -36934,7 +39078,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -36968,7 +39112,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; } @@ -37041,12 +39185,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; @@ -37124,37 +39268,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); @@ -37165,7 +39305,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); } @@ -37183,13 +39323,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))); } } } @@ -37197,58 +39337,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 === 226 + || kind === 197 + || 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 226: + case 197: + 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 { @@ -37296,20 +39436,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 171: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -37323,16 +39463,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; @@ -37356,10 +39496,13 @@ var ts; return serializedUnion; } } - case 159: case 160: + case 168: + case 169: + case 170: + case 161: case 118: - case 166: + case 167: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37401,15 +39544,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_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_27), ts.createLiteral("undefined")), name_27); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); } - return name_27; - case 140: + return name_33; + case 141: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -37483,7 +39626,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); @@ -37496,27 +39639,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]; @@ -37529,12 +39672,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; } @@ -37581,7 +39724,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)); @@ -37603,7 +39746,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); @@ -37639,39 +39782,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) { @@ -37706,9 +39842,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; @@ -37723,32 +39861,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_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 === 229) { + 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)) { @@ -37758,25 +39901,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) { @@ -37791,7 +39935,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227) { + if (body.kind === 231) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37814,13 +39958,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 227) { + if (body.kind !== 231) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226) { + if (moduleDeclaration.body.kind === 230) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -37840,7 +39984,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 233) { + if (node.kind === 237) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -37892,8 +40036,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 { @@ -37918,36 +40062,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); @@ -37957,40 +40085,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() { @@ -38010,15 +40119,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(254); - context.enableEmitNotification(226); + context.enableSubstitution(258); + context.enableEmitNotification(230); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226; + return ts.getOriginalNode(node).kind === 230; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 229; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38043,14 +40152,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_30 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_30); + 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_30, initializer, node); + return ts.createPropertyAssignment(name_35, initializer, node); } - return ts.createPropertyAssignment(name_30, exportedName, node); + return ts.createPropertyAssignment(name_35, exportedName, node); } } return node; @@ -38059,9 +40168,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 173: + case 177: return substitutePropertyAccessExpression(node); - case 174: + case 178: return substituteElementAccessExpression(node); } return node; @@ -38089,11 +40198,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 !== 261) { + var substitute = (applicableSubstitutions & 2 && container.kind === 230) || + (applicableSubstitutions & 8 && container.kind === 229); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38164,11 +40273,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242: + case 246: return visitJsxElement(node, false); - case 243: + case 247: return visitJsxSelfClosingElement(node, false); - case 248: + case 252: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38179,11 +40288,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 248: + case 252: return visitJsxExpression(node); - case 242: + case 246: return visitJsxElement(node, true); - case 243: + case 247: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38213,7 +40322,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); } @@ -38235,7 +40344,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 248) { + else if (node.kind === 252) { return visitJsxExpression(node); } else { @@ -38300,16 +40409,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242) { + if (node.kind === 246) { return getTagName(node.openingElement); } else { - var name_31 = node.tagName; - if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { - return ts.createLiteral(name_31.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_31); + return ts.createExpressionFromEntityName(name_36); } } } @@ -38586,12 +40695,165 @@ 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 176: + return visitObjectLiteralExpression(node); + case 192: + return visitBinaryExpression(node); + case 223: + return visitVariableDeclaration(node); + case 213: + return visitForOfStatement(node); + case 172: + case 173: + return node; + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + 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 === 259) { + 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 === 257) { + 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 !== 176) { + 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 === 172 && + !!(declaration.name.transformFlags & 8388608); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 176 && + 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 === 172 && + !!(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 ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); @@ -38614,10 +40876,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; @@ -38626,15 +40888,15 @@ var ts; switch (node.kind) { case 119: return undefined; - case 185: + case 189: return visitAwaitExpression(node); - case 148: + case 149: return visitMethodDeclaration(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); - case 181: + case 185: return visitArrowFunction(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38699,9 +40961,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 === 185; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; @@ -38744,12 +41007,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; @@ -38757,23 +41022,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(179); + context.enableSubstitution(177); + context.enableSubstitution(178); + context.enableEmitNotification(226); context.enableEmitNotification(149); + context.enableEmitNotification(151); + context.enableEmitNotification(152); + context.enableEmitNotification(150); } } function substituteExpression(node) { switch (node.kind) { - case 173: + case 177: return substitutePropertyAccessExpression(node); - case 174: + case 178: return substituteElementAccessExpression(node); - case 175: + case 179: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -38816,11 +41081,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 - || kind === 149 - || kind === 148 + return kind === 226 || kind === 150 - || kind === 151; + || kind === 149 + || kind === 151 + || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38866,10 +41131,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 { @@ -38878,7 +41143,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188: + case 192: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38921,28 +41186,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var ES2015SubstitutionFlags; - (function (ES2015SubstitutionFlags) { - ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -38960,6 +41203,7 @@ var ts; var enclosingFunction; var enclosingNonArrowFunction; var enclosingNonAsyncFunctionBody; + var isInConstructorWithCapturedSuper; var convertedLoopState; var enabledSubstitutions; return transformSourceFile; @@ -38989,11 +41233,14 @@ var ts; var savedCurrentParent = currentParent; var savedCurrentNode = currentNode; var savedConvertedLoopState = convertedLoopState; + var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; if (ts.nodeStartsNewLexicalEnvironment(node)) { + isInConstructorWithCapturedSuper = false; convertedLoopState = undefined; } onBeforeVisitNode(node); var visited = f(node); + isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; convertedLoopState = savedConvertedLoopState; enclosingFunction = savedEnclosingFunction; enclosingNonArrowFunction = savedEnclosingNonArrowFunction; @@ -39005,16 +41252,25 @@ var ts; currentNode = savedCurrentNode; return visited; } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + } + function isReturnVoidStatementInConstructorWithCapturedSuper(node) { + return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; + } function shouldCheckNode(node) { - return (node.transformFlags & 256) !== 0 || - node.kind === 215 || + return (node.transformFlags & 1024) !== 0 || + node.kind === 219 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { - if (shouldCheckNode(node)) { + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512) { + else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -39033,14 +41289,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212: + case 216: + node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201: + case 205: return visitVariableStatement(node); - case 214: + case 218: return visitSwitchStatement(node); - case 211: - case 210: + case 215: + case 214: return visitBreakOrContinueStatement(node); case 98: return visitThisKeyword(node); @@ -39052,74 +41309,76 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83: - return node; - case 222: + case 114: + return undefined; + case 226: return visitClassDeclaration(node); - case 193: + case 197: return visitClassExpression(node); - case 143: + case 144: return visitParameter(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 181: + case 185: return visitArrowFunction(node); - case 180: + case 184: return visitFunctionExpression(node); - case 219: + case 223: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 220: + case 224: return visitVariableDeclarationList(node); - case 215: + case 219: return visitLabeledStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); case 209: + return visitDoStatement(node); + case 210: + return visitWhileStatement(node); + case 211: + return visitForStatement(node); + case 212: + return visitForInStatement(node); + case 213: return visitForOfStatement(node); - case 203: + case 207: return visitExpressionStatement(node); - case 172: - return visitObjectLiteralExpression(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 171: - return visitArrayLiteralExpression(node); - case 175: - return visitCallExpression(node); case 176: - return visitNewExpression(node); + return visitObjectLiteralExpression(node); + case 256: + return visitCatchClause(node); + case 258: + return visitShorthandPropertyAssignment(node); + case 175: + return visitArrayLiteralExpression(node); case 179: + return visitCallExpression(node); + case 180: + return visitNewExpression(node); + case 183: return visitParenthesizedExpression(node, true); - case 188: + case 192: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 177: + case 181: return visitTaggedTemplateExpression(node); - case 190: + case 194: return visitTemplateExpression(node); - case 191: + case 195: return visitYieldExpression(node); case 96: return visitSuperKeyword(); - case 191: + case 195: return ts.visitEachChild(node, visitor, context); - case 148: + case 149: return visitMethodDeclaration(node); - case 256: + case 261: return visitSourceFileNode(node); - case 201: + case 205: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39134,7 +41393,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181) { + if (currentNode.kind !== 185) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39142,14 +41401,14 @@ var ts; } } switch (currentNode.kind) { - case 201: + case 205: enclosingVariableStatement = currentNode; break; - case 220: - case 219: - case 170: - case 168: - case 169: + case 224: + case 223: + case 174: + case 172: + case 173: break; default: enclosingVariableStatement = undefined; @@ -39177,7 +41436,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181) { + if (enclosingFunction && enclosingFunction.kind === 185) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39197,13 +41456,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 211 ? 2 : 4; + var jump = node.kind === 215 ? 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 === 215) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39213,7 +41472,7 @@ var ts; } } else { - if (node.kind === 211) { + if (node.kind === 215) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39243,26 +41502,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); @@ -39272,7 +41531,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); } @@ -39293,7 +41552,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); @@ -39308,13 +41567,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); } @@ -39337,8 +41596,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); @@ -39346,7 +41605,10 @@ var ts; statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); + var body = saveStateAndInvoke(constructor, function (constructor) { + isInConstructorWithCapturedSuper = superCaptureStatus === 1; + return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); + }); ts.addRange(statements, body); } if (extendsClauseElement @@ -39362,17 +41624,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 212) { + if (statement.kind === 216) { return true; } - else if (statement.kind === 204) { + else if (statement.kind === 208) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200) { + else if (statement.kind === 204) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39383,7 +41645,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0; } @@ -39392,7 +41654,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -39401,7 +41663,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 === 207 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39410,7 +41672,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; } @@ -39427,111 +41689,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_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_32)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_32, 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 203: 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); @@ -39596,7 +41780,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 262144) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39607,80 +41791,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 !== 185) { 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 183: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 188: + case 192: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39688,9 +41814,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 179: + case 183: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 188: + case 192: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39736,7 +41862,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); @@ -39755,8 +41881,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 - && enclosingBlockScopeContainer.kind !== 209 + && enclosingBlockScopeContainer.kind !== 212 + && enclosingBlockScopeContainer.kind !== 213 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39818,68 +41944,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; @@ -39887,8 +41952,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; } @@ -39943,11 +42008,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207: - case 208: - case 209: + case 211: + case 212: + case 213: var initializer = node.initializer; - if (initializer && initializer.kind === 220) { + if (initializer && initializer.kind === 224) { loopInitializer = initializer; } break; @@ -39986,7 +42051,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; @@ -39994,9 +42059,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) { @@ -40054,7 +42119,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 + statements.push(currentParent.kind === 219 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -40153,7 +42218,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 }); @@ -40166,20 +42231,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 257: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254: + case 258: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148: + case 149: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -40209,6 +42274,19 @@ var ts; } return expression; } + function visitCatchClause(node) { + ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + function addStatementToStartOfBlock(block, statement) { + var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); + return ts.updateBlock(block, [statement].concat(transformedStatements)); + } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); @@ -40236,7 +42314,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 { @@ -40253,35 +42331,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 !== 175 ? 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) { @@ -40354,7 +42432,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 175 + && currentParent.kind !== 179 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40363,7 +42441,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); @@ -40388,13 +42466,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(185); + context.enableEmitNotification(184); + context.enableEmitNotification(225); } } function onSubstituteNode(emitContext, node) { @@ -40419,10 +42497,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170: - case 222: - case 225: - case 219: + case 174: + case 226: + case 229: + case 223: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40454,28 +42532,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_33 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_33, emitFlags); - } - return name_33; - } - 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) { @@ -40487,11 +42545,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 !== 207) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179) { return false; } var callTarget = statementExpression.expression; @@ -40499,7 +42557,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 !== 196) { return false; } var expression = callArgument.expression; @@ -40510,51 +42568,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var OpCode; - (function (OpCode) { - OpCode[OpCode["Nop"] = 0] = "Nop"; - OpCode[OpCode["Statement"] = 1] = "Statement"; - OpCode[OpCode["Assign"] = 2] = "Assign"; - OpCode[OpCode["Break"] = 3] = "Break"; - OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; - OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; - OpCode[OpCode["Yield"] = 6] = "Yield"; - OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; - OpCode[OpCode["Return"] = 8] = "Return"; - OpCode[OpCode["Throw"] = 9] = "Throw"; - OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; - })(OpCode || (OpCode = {})); - var BlockAction; - (function (BlockAction) { - BlockAction[BlockAction["Open"] = 0] = "Open"; - BlockAction[BlockAction["Close"] = 1] = "Close"; - })(BlockAction || (BlockAction = {})); - var CodeBlockKind; - (function (CodeBlockKind) { - CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; - CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; - CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; - CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; - CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; - })(CodeBlockKind || (CodeBlockKind = {})); - var ExceptionBlockState; - (function (ExceptionBlockState) { - ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; - ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; - ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; - ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; - })(ExceptionBlockState || (ExceptionBlockState = {})); - var Instruction; - (function (Instruction) { - Instruction[Instruction["Next"] = 0] = "Next"; - Instruction[Instruction["Throw"] = 1] = "Throw"; - Instruction[Instruction["Return"] = 2] = "Return"; - Instruction[Instruction["Break"] = 3] = "Break"; - Instruction[Instruction["Yield"] = 4] = "Yield"; - Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; - Instruction[Instruction["Catch"] = 6] = "Catch"; - Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; - })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40600,7 +42613,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; @@ -40615,10 +42628,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 { @@ -40627,13 +42640,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205: + case 209: return visitDoStatement(node); - case 206: + case 210: return visitWhileStatement(node); - case 214: + case 218: return visitSwitchStatement(node); - case 215: + case 219: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40641,30 +42654,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); - case 150: case 151: + case 152: return visitAccessorDeclaration(node); - case 201: + case 205: return visitVariableStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); case 211: - return visitBreakStatement(node); - case 210: - return visitContinueStatement(node); + return visitForStatement(node); case 212: + return visitForInStatement(node); + case 215: + return visitBreakStatement(node); + case 214: + return visitContinueStatement(node); + case 216: 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 { @@ -40674,21 +42687,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188: + case 192: return visitBinaryExpression(node); - case 189: + case 193: return visitConditionalExpression(node); - case 191: + case 195: return visitYieldExpression(node); - case 171: - return visitArrayLiteralExpression(node); - case 172: - return visitObjectLiteralExpression(node); - case 174: - return visitElementAccessExpression(node); case 175: - return visitCallExpression(node); + return visitArrayLiteralExpression(node); case 176: + return visitObjectLiteralExpression(node); + case 178: + return visitElementAccessExpression(node); + case 179: + return visitCallExpression(node); + case 180: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40696,9 +42709,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 221: + case 225: return visitFunctionDeclaration(node); - case 180: + case 184: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40801,7 +42814,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; } @@ -40855,10 +42868,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173: + case 177: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174: + case 178: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -41050,35 +43063,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); - case 206: - return transformAndEmitWhileStatement(node); + return transformAndEmitBlock(node); case 207: - return transformAndEmitForStatement(node); + return transformAndEmitExpressionStatement(node); case 208: - return transformAndEmitForInStatement(node); + return transformAndEmitIfStatement(node); + case 209: + return transformAndEmitDoStatement(node); case 210: - return transformAndEmitContinueStatement(node); + return transformAndEmitWhileStatement(node); case 211: - return transformAndEmitBreakStatement(node); + return transformAndEmitForStatement(node); case 212: - return transformAndEmitReturnStatement(node); - case 213: - return transformAndEmitWithStatement(node); + return transformAndEmitForInStatement(node); case 214: - return transformAndEmitSwitchStatement(node); + return transformAndEmitContinueStatement(node); case 215: - return transformAndEmitLabeledStatement(node); + return transformAndEmitBreakStatement(node); case 216: - return transformAndEmitThrowStatement(node); + return transformAndEmitReturnStatement(node); case 217: + return transformAndEmitWithStatement(node); + case 218: + return transformAndEmitSwitchStatement(node); + case 219: + return transformAndEmitLabeledStatement(node); + case 220: + return transformAndEmitThrowStatement(node); + case 221: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41362,7 +43375,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 === 254 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -41372,7 +43385,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 === 253) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -41463,7 +43476,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; @@ -41493,9 +43506,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_34) { - var clone_8 = ts.getMutableClone(name_34); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_8 = ts.getMutableClone(name_37); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -41794,7 +43807,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -41803,7 +43816,7 @@ var ts; } return expression; } - return ts.createNode(194); + return ts.createOmittedExpression(); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41891,7 +43904,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() { @@ -42162,8 +44175,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(253); + context.enableSubstitution(177); + context.enableSubstitution(257); return transformSourceFile; function transformSourceFile(node) { return node; @@ -42222,48 +44235,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(192); + context.enableSubstitution(190); + context.enableSubstitution(191); + context.enableSubstitution(258); + context.enableEmitNotification(261); + 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; @@ -42280,77 +44285,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 235: return visitImportDeclaration(node); - case 230: + case 234: return visitImportEqualsDeclaration(node); - case 237: + case 241: return visitExportDeclaration(node); - case 236: + case 240: return visitExportAssignment(node); - case 201: + case 205: return visitVariableStatement(node); - case 221: + case 225: return visitFunctionDeclaration(node); - case 222: + case 226: return visitClassDeclaration(node); - case 203: - return visitExpressionStatement(node); + case 294: + return visitMergeDeclarationMarker(node); + case 295: + 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 = []; @@ -42363,43 +44396,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); @@ -42413,7 +44463,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); } @@ -42429,195 +44479,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_35 = names_1[_i]; - addExportMemberAssignments(statements, name_35); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_36 = node.name; - if (ts.isIdentifier(name_36)) { - names.push(name_36); - } - } - 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 === 205) { + 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 237: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238: + 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 === 261) { + 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); @@ -42625,6 +44728,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); } @@ -42649,141 +44755,82 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 188: + case 192: return substituteBinaryExpression(node); - case 187: - case 186: + case 191: + case 190: 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 === 261) { + 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 === 191 + ? 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_37 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), 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; } @@ -42792,7 +44839,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(); @@ -42801,696 +44848,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(192); + context.enableSubstitution(190); + context.enableSubstitution(191); + context.enableEmitNotification(261); + 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_38 = node.name || ts.getGeneratedNameForNode(node); - var isAsync = ts.hasModifier(node, 256); - var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_38); - } - 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_39 = getDeclarationName(originalNode); - if (originalNode.kind === 225) { - hoistVariableDeclaration(name_39); - } - return [ - node, - createExportStatement(name_39, name_39) - ]; - } - 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(); @@ -43502,7 +44911,6 @@ var ts; if (ts.hasProperty(groupIndices, text)) { var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; } else { groupIndices[text] = dependencyGroups.length; @@ -43514,47 +44922,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 === 241 && 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 !== 241) { + 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 235: + if (!entry.importClause) { + break; + } + case 234: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 241: + 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 235: + return visitImportDeclaration(node); + case 234: + return visitImportEqualsDeclaration(node); + case 241: + return undefined; + case 240: + 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 === 261 + || (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 === 205) { + 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 237: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238: + 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 205: + return visitVariableStatement(node); + case 225: + return visitFunctionDeclaration(node); + case 226: + return visitClassDeclaration(node); + case 211: + return visitForStatement(node); + case 212: + return visitForInStatement(node); + case 213: + return visitForOfStatement(node); + case 209: + return visitDoStatement(node); + case 210: + return visitWhileStatement(node); + case 219: + return visitLabeledStatement(node); + case 217: + return visitWithStatement(node); + case 218: + return visitSwitchStatement(node); + case 232: + return visitCaseBlock(node); + case 253: + return visitCaseClause(node); + case 254: + return visitDefaultClause(node); + case 221: + return visitTryStatement(node); + case 256: + return visitCatchClause(node); + case 204: + return visitBlock(node); + case 294: + return visitMergeDeclarationMarker(node); + case 295: + 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 === 192) { + 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 === 261; + } + 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 === 261) { + 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 192: + return substituteBinaryExpression(node); + case 190: + case 191: + 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 === 191 + ? 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 === 191) { + 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 === 261) { + 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; @@ -43575,9 +45658,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 234: return undefined; - case 236: + case 240: return visitExportAssignment(node); } return node; @@ -43598,21 +45681,18 @@ var ts; _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); - var SyntaxKindFeatureFlags; - (function (SyntaxKindFeatureFlags) { - SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; - SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; - })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); 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); } @@ -43623,6 +45703,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); } @@ -43632,7 +45713,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289); + var enabledSyntaxKindFeatures = new Array(296); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -43785,7 +45866,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? ts.noop : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -43829,7 +45910,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 === 235); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43900,10 +45981,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219) { + if (declaration.kind === 223) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { + else if (declaration.kind === 238 || declaration.kind === 239 || declaration.kind === 236) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43914,7 +45995,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 === 235) { moduleElementEmitInfo.isVisible = true; } else { @@ -43922,12 +46003,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 230) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 230) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -44040,43 +46121,49 @@ 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 171: return writeTextOfNode(currentText, type); - case 195: + case 199: 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 emitIndexedAccessType(type); + case 170: + return emitMappedType(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) { @@ -44084,22 +46171,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 === 234 ? 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 === 177); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44145,6 +46232,42 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitIndexedAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } + function emitMappedType(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + writeEntityName(node.typeParameter.name); + write(" in "); + emitType(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emitType(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + enclosingDeclaration = prevEnclosingDeclaration; + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -44173,9 +46296,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -44219,10 +46342,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 || - (node.parent.kind === 256 && isCurrentFileExternalModule)) { + else if (node.kind === 234 || + (node.parent.kind === 261 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -44231,7 +46354,7 @@ var ts; }); } else { - if (node.kind === 231) { + if (node.kind === 235) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44249,30 +46372,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 205: + return writeVariableStatement(node); + case 227: + return writeInterfaceDeclaration(node); case 226: - return writeModuleDeclaration(node); + return writeClassDeclaration(node); + case 228: + return writeTypeAliasDeclaration(node); + case 229: + return writeEnumDeclaration(node); case 230: + return writeModuleDeclaration(node); + case 234: return writeImportEqualsDeclaration(node); - case 231: + case 235: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 256) { + if (node.parent.kind === 261) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -44280,7 +46403,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 223 && !noDeclare) { + else if (node.kind !== 227 && !noDeclare) { write("declare "); } } @@ -44330,7 +46453,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 237) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44353,7 +46476,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 233) { + if (node.importClause.namedBindings.kind === 237) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44370,13 +46493,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 230; var moduleSpecifier; - if (parent.kind === 230) { + if (parent.kind === 234) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226) { + else if (parent.kind === 230) { moduleSpecifier = parent.name; } else { @@ -44444,7 +46567,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227) { + while (node.body && node.body.kind !== 231) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44514,7 +46637,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) { @@ -44524,15 +46647,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 { @@ -44542,31 +46665,31 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 222: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223: + case 227: 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 === 226) { 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 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44603,7 +46726,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 226) { 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; @@ -44683,17 +46806,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 223 || 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)) { @@ -44706,14 +46829,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219) { + if (node.kind === 223) { 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 ? @@ -44721,7 +46844,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 === 226) { 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 : @@ -44747,7 +46870,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 !== 198) { elements.push(element); } } @@ -44813,7 +46936,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; @@ -44826,7 +46949,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 @@ -44835,7 +46958,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 : @@ -44881,17 +47004,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221) { + if (node.kind === 225) { 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 === 225) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149) { + else if (node.kind === 150) { write("constructor"); } else { @@ -44911,15 +47034,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; @@ -44930,20 +47053,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; @@ -44957,23 +47080,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 ? @@ -44981,7 +47104,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 === 226) { 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 : @@ -44994,7 +47117,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221: + case 225: 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 : @@ -45026,9 +47149,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)) { @@ -45044,22 +47167,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 ? @@ -45067,7 +47190,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 === 226) { 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 : @@ -45079,7 +47202,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 225: 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 : @@ -45090,12 +47213,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 172) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 173) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -45106,10 +47229,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194) { + if (bindingElement.kind === 198) { write(" "); } - else if (bindingElement.kind === 170) { + else if (bindingElement.kind === 174) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45131,39 +47254,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221: - case 226: - case 230: - case 223: - case 222: - case 224: case 225: + case 230: + case 234: + case 227: + case 226: + case 228: + case 229: return emitModuleElement(node, isModuleElementVisible(node)); - case 201: + case 205: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231: + case 235: return emitModuleElement(node, !node.importClause); - case 237: + case 241: 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 260: return emitEnumMemberDeclaration(node); - case 236: + case 240: return emitExportAssignment(node); - case 256: + case 261: return emitSourceFile(node); } } @@ -45380,7 +47503,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 !== 292 && (emitFlags & 512) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -45393,7 +47516,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 + if (node.kind !== 292 && (emitFlags & 1024) === 0 && end >= 0) { emitPos(end); @@ -45537,7 +47660,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287; + var isEmittedNode = node.kind !== 292; var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -45551,7 +47674,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 220) { + if (node.kind === 224) { declarationListContainerEnd = end; } } @@ -45751,12 +47874,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var TempFlags; - (function (TempFlags) { - TempFlags[TempFlags["Auto"] = 0] = "Auto"; - TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; - TempFlags[TempFlags["_i"] = 268435456] = "_i"; - })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { @@ -45764,6 +47881,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};"; @@ -45796,6 +47914,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -45929,7 +48048,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 256: + case 261: return emitSourceFile(node); } } @@ -45967,7 +48086,6 @@ var ts; case 123: case 124: case 125: - case 126: case 127: case 128: case 129: @@ -45981,182 +48099,191 @@ 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); - case 198: - return emitTemplateSpan(node); + return emitParenthesizedType(node); case 199: - return emitSemicolonClassElement(); - case 200: - return emitBlock(node); - case 201: - return emitVariableStatement(node); + return emitExpressionWithTypeArguments(node); + case 167: + return emitThisType(); + case 168: + return emitTypeOperator(node); + case 169: + return emitIndexedAccessType(node); + case 170: + return emitMappedType(node); + case 171: + return emitLiteralType(node); + case 172: + return emitObjectBindingPattern(node); + case 173: + return emitArrayBindingPattern(node); + case 174: + return emitBindingElement(node); case 202: - return emitEmptyStatement(); + return emitTemplateSpan(node); case 203: - return emitExpressionStatement(node); + return emitSemicolonClassElement(); case 204: - return emitIfStatement(node); + return emitBlock(node); case 205: - return emitDoStatement(node); + return emitVariableStatement(node); case 206: - return emitWhileStatement(node); + return emitEmptyStatement(); case 207: - return emitForStatement(node); + return emitExpressionStatement(node); case 208: - return emitForInStatement(node); + return emitIfStatement(node); case 209: - return emitForOfStatement(node); + return emitDoStatement(node); case 210: - return emitContinueStatement(node); + return emitWhileStatement(node); case 211: - return emitBreakStatement(node); + return emitForStatement(node); case 212: - return emitReturnStatement(node); + return emitForInStatement(node); case 213: - return emitWithStatement(node); + return emitForOfStatement(node); case 214: - return emitSwitchStatement(node); + return emitContinueStatement(node); case 215: - return emitLabeledStatement(node); + return emitBreakStatement(node); case 216: - return emitThrowStatement(node); + return emitReturnStatement(node); case 217: - return emitTryStatement(node); + return emitWithStatement(node); case 218: - return emitDebuggerStatement(node); + return emitSwitchStatement(node); case 219: - return emitVariableDeclaration(node); + return emitLabeledStatement(node); case 220: - return emitVariableDeclarationList(node); + return emitThrowStatement(node); case 221: - return emitFunctionDeclaration(node); + return emitTryStatement(node); case 222: - return emitClassDeclaration(node); + return emitDebuggerStatement(node); case 223: - return emitInterfaceDeclaration(node); + return emitVariableDeclaration(node); case 224: - return emitTypeAliasDeclaration(node); + return emitVariableDeclarationList(node); case 225: - return emitEnumDeclaration(node); + return emitFunctionDeclaration(node); case 226: - return emitModuleDeclaration(node); + return emitClassDeclaration(node); case 227: - return emitModuleBlock(node); + return emitInterfaceDeclaration(node); case 228: - return emitCaseBlock(node); + return emitTypeAliasDeclaration(node); + case 229: + return emitEnumDeclaration(node); case 230: - return emitImportEqualsDeclaration(node); + return emitModuleDeclaration(node); case 231: - return emitImportDeclaration(node); + return emitModuleBlock(node); case 232: - return emitImportClause(node); - case 233: - return emitNamespaceImport(node); + return emitCaseBlock(node); case 234: - return emitNamedImports(node); + return emitImportEqualsDeclaration(node); case 235: - return emitImportSpecifier(node); + return emitImportDeclaration(node); case 236: - return emitExportAssignment(node); + return emitImportClause(node); case 237: - return emitExportDeclaration(node); + return emitNamespaceImport(node); case 238: - return emitNamedExports(node); + return emitNamedImports(node); case 239: - return emitExportSpecifier(node); + return emitImportSpecifier(node); case 240: - return; + return emitExportAssignment(node); case 241: + return emitExportDeclaration(node); + case 242: + return emitNamedExports(node); + case 243: + return emitExportSpecifier(node); + case 244: + return; + case 245: 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); case 248: - return emitJsxExpression(node); + return emitJsxOpeningElement(node); case 249: - return emitCaseClause(node); + return emitJsxClosingElement(node); case 250: - return emitDefaultClause(node); + return emitJsxAttribute(node); case 251: - return emitHeritageClause(node); + return emitJsxSpreadAttribute(node); case 252: - return emitCatchClause(node); + return emitJsxExpression(node); case 253: - return emitPropertyAssignment(node); + return emitCaseClause(node); case 254: - return emitShorthandPropertyAssignment(node); + return emitDefaultClause(node); case 255: + return emitHeritageClause(node); + case 256: + return emitCatchClause(node); + case 257: + return emitPropertyAssignment(node); + case 258: + return emitShorthandPropertyAssignment(node); + case 259: + return emitSpreadAssignment(node); + case 260: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -46181,63 +48308,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); case 175: - return emitCallExpression(node); + return emitArrayLiteralExpression(node); case 176: - return emitNewExpression(node); + return emitObjectLiteralExpression(node); case 177: - return emitTaggedTemplateExpression(node); + return emitPropertyAccessExpression(node); case 178: - return emitTypeAssertionExpression(node); + return emitElementAccessExpression(node); case 179: - return emitParenthesizedExpression(node); + return emitCallExpression(node); case 180: - return emitFunctionExpression(node); + return emitNewExpression(node); case 181: - return emitArrowFunction(node); + return emitTaggedTemplateExpression(node); case 182: - return emitDeleteExpression(node); + return emitTypeAssertionExpression(node); case 183: - return emitTypeOfExpression(node); + return emitParenthesizedExpression(node); case 184: - return emitVoidExpression(node); + return emitFunctionExpression(node); case 185: - return emitAwaitExpression(node); + return emitArrowFunction(node); case 186: - return emitPrefixUnaryExpression(node); + return emitDeleteExpression(node); case 187: - return emitPostfixUnaryExpression(node); + return emitTypeOfExpression(node); case 188: - return emitBinaryExpression(node); + return emitVoidExpression(node); case 189: - return emitConditionalExpression(node); + return emitAwaitExpression(node); case 190: - return emitTemplateExpression(node); + return emitPrefixUnaryExpression(node); case 191: - return emitYieldExpression(node); + return emitPostfixUnaryExpression(node); case 192: - return emitSpreadElementExpression(node); + return emitBinaryExpression(node); case 193: - return emitClassExpression(node); + return emitConditionalExpression(node); case 194: - return; + return emitTemplateExpression(node); + case 195: + return emitYieldExpression(node); case 196: - return emitAsExpression(node); + return emitSpreadExpression(node); case 197: + return emitClassExpression(node); + case 198: + return; + case 200: + return emitAsExpression(node); + case 201: return emitNonNullExpression(node); - case 242: + case 246: return emitJsxElement(node); - case 243: + case 247: return emitJsxSelfClosingElement(node); - case 288: + case 293: return emitPartiallyEmittedExpression(node); } } @@ -46341,7 +48468,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); } @@ -46426,6 +48553,39 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitIndexedAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } + function emitMappedType(node) { + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + emit(node.typeParameter.name); + write(" in "); + emit(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emit(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -46589,7 +48749,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 186 + return operand.kind === 190 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -46633,7 +48793,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -46701,7 +48861,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 204) { + if (node.elseStatement.kind === 208) { write(" "); emit(node.elseStatement); } @@ -46763,7 +48923,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220) { + if (node.kind === 224) { emit(node); } else { @@ -46992,7 +49152,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226) { + while (body.kind === 230) { write("."); emit(body.name); body = body.body; @@ -47211,6 +49371,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); @@ -47280,10 +49446,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) { @@ -47606,7 +49779,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 && ts.nodeIsSynthesized(node)) { + while (node.kind === 183 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -47663,21 +49836,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_40 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_41; + return name_40; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -47715,17 +49888,17 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 226: - case 225: + case 230: + case 229: return generateNameForModuleOrEnum(node); - case 231: - case 237: + case 235: + case 241: return generateNameForImportOrExportDeclaration(node); - case 221: - case 222: - case 236: + case 225: + case 226: + case 240: return generateNameForExportDefault(); - case 193: + case 197: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -47795,72 +49968,10 @@ var ts; } } ts.emitFiles = emitFiles; - var ListFormat; - (function (ListFormat) { - ListFormat[ListFormat["None"] = 0] = "None"; - ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; - ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; - ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; - ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; - ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; - ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; - ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; - ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; - ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; - ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; - })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.0"; + ts.version = "2.2.0"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -48075,11 +50186,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_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; @@ -48093,7 +50204,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(); @@ -48106,7 +50217,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; }; @@ -48168,6 +50286,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -48175,12 +50294,13 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); return program; function getCommonSourceDirectory() { - if (typeof commonSourceDirectory === "undefined") { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + if (commonSourceDirectory === undefined) { + var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } else { - commonSourceDirectory = computeCommonSourceDirectory(files); + commonSourceDirectory = computeCommonSourceDirectory(emittedFiles); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { commonSourceDirectory += ts.directorySeparator; @@ -48199,26 +50319,85 @@ 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; } var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.moduleResolution !== options.moduleResolution) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx) || - (oldOptions.allowJs !== options.allowJs) || - (oldOptions.rootDir !== options.rootDir) || - (oldOptions.configFilePath !== options.configFilePath) || - (oldOptions.baseUrl !== options.baseUrl) || - (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || - !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || - !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || - !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !ts.equalOwnProperties(oldOptions.paths, options.paths)) { + if (ts.changesAffectModuleResolution(oldOptions, options)) { return false; } ts.Debug.assert(!oldProgram.structureIsReused); @@ -48259,40 +50438,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; @@ -48308,11 +50491,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)); } @@ -48389,6 +50575,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) { @@ -48408,183 +50600,170 @@ 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 181: - case 221: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + case 152: + case 184: + case 225: + case 185: + case 225: + case 223: + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } + } + switch (node.kind) { + case 234: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 240: + if (node.isExportEquals) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; } break; - case 201: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; + case 255: + 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 219: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; + case 227: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 230: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 228: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 229: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 182: + 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 226: + case 149: + case 148: + case 150: + case 151: + case 152: + case 184: + case 225: + case 185: + case 225: + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + case 205: + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 205); } 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 179: + case 180: + case 199: + 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); } }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -48601,9 +50780,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); } @@ -48622,14 +50798,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(235); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -48641,12 +50821,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 235: + case 234: + case 241: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -48658,13 +50839,16 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226: + case 230: 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++) { @@ -48688,7 +50872,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("', '") + "'"]; @@ -48749,7 +50933,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); } @@ -48821,9 +51005,11 @@ var ts; } else { if (previousResolution) { - var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); - if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { + var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); + if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + } } saveResolution = false; } @@ -48858,23 +51044,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--; @@ -48884,7 +51078,6 @@ var ts; else { file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -49038,7 +51231,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) { @@ -49053,10 +51254,15 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + 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)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); } else { emitFilesSeen.set(emitFilePath, true); @@ -49064,1096 +51270,33 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, message) { + function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + programDiagnostics.add(diag); } } ts.createProgram = createProgram; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message, - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, - }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2, - "es2016": 3, - "es2017": 4, - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.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" - }), - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } - ]; - ts.typingOptionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean", - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" - } - } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false, - }; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - var key = trimString((value || "")).toLowerCase(); - var map = opt.type; - if (key in map) { - return map[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; - } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); - } - } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); - } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } - } - return undefined; + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } - 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) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_44] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_44] = convertedValue; - } - else { - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } - } - } - return result; + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; } } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; - } - } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typingOptions: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; - } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = ts.assign({}, baseOptions, options); - } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typingOptions: typingOptions, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; - } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } - else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); - } - } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; - } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; - } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); - return options; - } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; - } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); - } - } - } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); - } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); - } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - } - return value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); - } - } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); - } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; - } - } - } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; - } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; - } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - 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)) { - continue; - } - var match = wildcardDirectoryPattern.exec(name_45); - if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_45) ? 1 : 0; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } - } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } - } - } - return wildcardDirectories; - } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { - return true; - } - } - return false; - } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } - } - function addFileToOutput(output, file) { - output.push(file); - return output; - } - function caseSensitiveKeyMapper(key) { - return key; - } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); - } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; (function (ts) { @@ -50192,12 +51335,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"; @@ -50221,24 +51365,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; - (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; - (function (EndOfLineState) { - EndOfLineState[EndOfLineState["None"] = 0] = "None"; - EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; - EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; - EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; - EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; + })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -50249,8 +51377,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 = ""; @@ -50326,75 +51453,40 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; - (function (ClassificationType) { - ClassificationType[ClassificationType["comment"] = 1] = "comment"; - ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; - ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; - ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; - ClassificationType[ClassificationType["operator"] = 5] = "operator"; - ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; - ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; - ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; - ClassificationType[ClassificationType["text"] = 9] = "text"; - ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; - ClassificationType[ClassificationType["className"] = 11] = "className"; - ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; - ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; - ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; - ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; - ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; - ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; - ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; - ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; - ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; - ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; - ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; - ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; - ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(4, true); + ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; - (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; 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 223: + case 174: case 147: + case 146: + case 257: + case 258: + case 260: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 252: - return 1; - case 142: - case 223: - case 224: - case 160: - return 2; - case 222: + case 152: case 225: - return 1 | 2; + case 184: + case 185: + case 256: + return 1; + case 143: + case 227: + case 228: + case 161: + return 2; case 226: + case 229: + return 1 | 2; + case 230: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -50404,21 +51496,21 @@ var ts; else { return 4; } + case 238: + case 239: case 234: case 235: - case 230: - case 231: - case 236: - case 237: + case 240: + case 241: return 1 | 2 | 4; - case 256: + case 261: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 236) { + if (node.parent.kind === 240) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -50440,15 +51532,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 === 234) { 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; @@ -50459,27 +51551,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 === 177) { + while (root.parent && root.parent.kind === 177) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 199 && root.parent.parent.kind === 255) { 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 === 226 && root.parent.parent.token === 107) || + (decl.kind === 227 && root.parent.parent.token === 84); } return false; } @@ -50487,17 +51579,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 === 199 && !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, 179); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176); + return isCallOrNewExpressionTarget(node, 180); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -50510,7 +51602,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 219 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -50520,13 +51612,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 211 || node.parent.kind === 210) && + (node.parent.kind === 215 || node.parent.kind === 214) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 215 && + node.parent.kind === 219 && node.parent.label === node; } function isLabelName(node) { @@ -50534,15 +51626,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 === 177 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 226 && node.parent.name === node; + return node.parent.kind === 230 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -50553,19 +51645,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 257: + case 260: + case 149: + case 148: case 151: - case 226: + case 152: + case 230: return node.parent.name === node; - case 174: + case 178: return node.parent.argumentExpression === node; - case 141: + case 142: return true; } } @@ -50609,17 +51701,17 @@ var ts; return undefined; } switch (node.kind) { - case 256: + case 261: + case 149: case 148: - case 147: - case 221: - case 180: - case 150: - case 151: - case 222: - case 223: case 225: + case 184: + case 151: + case 152: case 226: + case 227: + case 229: + case 230: return node; } } @@ -50627,46 +51719,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256: + case 261: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226: - return ts.ScriptElementKind.moduleElement; - case 222: - case 193: - return ts.ScriptElementKind.classElement; - case 223: return ts.ScriptElementKind.interfaceElement; - case 224: return ts.ScriptElementKind.typeElement; - case 225: return ts.ScriptElementKind.enumElement; - case 219: - return getKindOfVariableDeclaration(node); - case 170: - return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181: - case 221: - case 180: - return ts.ScriptElementKind.functionElement; - case 150: return ts.ScriptElementKind.memberGetAccessorElement; - case 151: return ts.ScriptElementKind.memberSetAccessorElement; - case 148: - case 147: - return ts.ScriptElementKind.memberFunctionElement; - 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: + return ts.ScriptElementKind.moduleElement; + case 226: + case 197: + return ts.ScriptElementKind.classElement; + case 227: return ts.ScriptElementKind.interfaceElement; + case 228: return ts.ScriptElementKind.typeElement; + case 229: return ts.ScriptElementKind.enumElement; + case 223: + return getKindOfVariableDeclaration(node); + case 174: + return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 185: + case 225: + case 184: + return ts.ScriptElementKind.functionElement; + case 151: return ts.ScriptElementKind.memberGetAccessorElement; + case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 149: + case 148: + return ts.ScriptElementKind.memberFunctionElement; + case 147: + case 146: + return ts.ScriptElementKind.memberVariableElement; + 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 260: return ts.ScriptElementKind.enumMemberElement; + case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 234: case 239: - case 233: + case 236: + case 243: + case 237: return ts.ScriptElementKind.alias; - case 279: + case 284: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -50681,7 +51773,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 167 ? node.parent : node; + var searchNode = node.parent.kind === 171 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -50694,7 +51786,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; } @@ -50738,41 +51830,41 @@ var ts; return false; } switch (n.kind) { - case 222: - case 223: - case 225: - case 172: - case 168: - case 160: - case 200: + case 226: case 227: - case 228: - case 234: - case 238: - return nodeEndsWith(n, 17, sourceFile); - case 252: - return isCompletedNode(n.block, sourceFile); + case 229: case 176: + case 172: + case 161: + case 204: + case 231: + case 232: + case 238: + case 242: + return nodeEndsWith(n, 17, sourceFile); + case 256: + return isCompletedNode(n.block, sourceFile); + case 180: if (!n.arguments) { return true; } - case 175: case 179: - case 165: + case 183: + 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 225: + case 184: + case 149: + case 148: + case 154: + case 153: + case 185: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -50780,65 +51872,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 226: + case 230: return n.body && isCompletedNode(n.body, sourceFile); - case 204: + case 208: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203: + case 207: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 171: - case 169: - case 174: - case 141: - case 162: + case 175: + case 173: + case 178: + 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 253: + case 254: return false; - case 207: - case 208: - case 209: - case 206: + case 211: + case 212: + case 213: + case 210: return isCompletedNode(n.statement, sourceFile); - case 205: + case 209: 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 187: + case 186: + case 188: + case 195: + case 196: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177: + case 181: return isCompletedNode(n.template, sourceFile); - case 190: + case 194: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198: + case 202: return ts.nodeIsPresent(n.literal); - case 237: - case 231: + case 241: + case 235: return ts.nodeIsPresent(n.moduleSpecifier); - case 186: + case 190: return isCompletedNode(n.operand, sourceFile); - case 188: + case 192: return isCompletedNode(n.right, sourceFile); - case 189: + case 193: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -50881,7 +51973,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 === 291 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -51016,7 +52108,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256); + ts.Debug.assert(startNode !== undefined || n.kind === 261); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -51061,13 +52153,13 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 248) { + if (token.kind === 26 && token.parent.kind === 252) { return true; } - if (token && token.kind === 17 && token.parent.kind === 248) { + if (token && token.kind === 17 && token.parent.kind === 252) { return true; } - if (token.kind === 26 && token.parent.kind === 245) { + if (token.kind === 26 && token.parent.kind === 249) { return true; } return false; @@ -51158,17 +52250,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 156 || node.kind === 175) { + if (node.kind === 157 || node.kind === 179) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { + if (ts.isFunctionLike(node) || node.kind === 226 || node.kind === 227) { 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) { @@ -51227,18 +52319,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 || - node.kind === 172) { - if (node.parent.kind === 188 && + if (node.kind === 175 || + node.kind === 176) { + if (node.parent.kind === 192 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 209 && + if (node.parent.kind === 213 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 257 ? node.parent.parent : node.parent)) { return true; } } @@ -51269,7 +52361,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(); @@ -51291,8 +52383,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; function writeIndent() { if (lineStart) { @@ -51444,7 +52536,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); @@ -51454,7 +52546,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 235 || location.parent.kind === 239) && + (location.parent.kind === 239 || location.parent.kind === 243) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -51559,89 +52651,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201: + case 205: 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 223: case 147: - case 150: - case 151: + case 146: + return spanInVariableDeclaration(node); + case 144: + return spanInParameterDeclaration(node); + case 225: case 149: - case 180: - case 181: + case 148: + case 151: + case 152: + case 150: + case 184: + case 185: return spanInFunctionDeclaration(node); - case 200: + case 204: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 227: + case 231: return spanInBlock(node); - case 252: + case 256: 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 textSpan(node.expression); + case 216: + return textSpan(node.getChildAt(0), node.expression); + case 210: return textSpanEndingAtNextToken(node, node.expression); case 209: - return spanInInitializerOfForLike(node); - case 214: + return spanInNode(node.statement); + case 222: + return textSpan(node.getChildAt(0)); + case 208: return textSpanEndingAtNextToken(node, node.expression); - case 249: - case 250: + case 219: + return spanInNode(node.statement); + case 215: + case 214: + return textSpan(node.getChildAt(0), node.label); + case 211: + return spanInForStatement(node); + case 212: + return textSpanEndingAtNextToken(node, node.expression); + case 213: + return spanInInitializerOfForLike(node); + case 218: + return textSpanEndingAtNextToken(node, node.expression); + case 253: + case 254: return spanInNode(node.statements[0]); - case 217: + case 221: return spanInBlock(node.tryBlock); - case 216: + case 220: return textSpan(node, node.expression); - case 236: + case 240: return textSpan(node, node.expression); - case 230: + case 234: return textSpan(node, node.moduleReference); - case 231: + case 235: return textSpan(node, node.moduleSpecifier); - case 237: + case 241: return textSpan(node, node.moduleSpecifier); - case 226: + case 230: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 222: - case 225: - case 255: - case 170: + case 226: + case 229: + case 260: + case 174: return textSpan(node); - case 213: + case 217: return spanInNode(node.statement); - case 144: + case 145: return spanInNodeArray(node.parent.decorators); - case 168: - case 169: + case 172: + case 173: return spanInBindingPattern(node); - case 223: - case 224: + case 227: + case 228: return undefined; case 24: case 1: @@ -51669,20 +52761,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 == 196 || + node.kind === 257 || + node.kind === 258) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188) { + if (node.kind === 192) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -51697,38 +52789,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205: - return spanInPreviousNode(node); - case 144: - return spanInNode(node.parent); - case 207: case 209: + return spanInPreviousNode(node); + case 145: + return spanInNode(node.parent); + case 211: + case 213: return textSpan(node); - case 188: + case 192: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 181: + case 185: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 253 && + if (node.parent.kind === 257 && 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 === 182 && 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 === 223 || + node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -51736,7 +52828,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188) { + if (node.parent.kind === 192) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -51757,7 +52849,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 208) { + if (variableDeclaration.parent.parent.kind === 212) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -51765,7 +52857,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 209) { + variableDeclaration.parent.parent.kind === 213) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -51797,7 +52889,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); + (functionDeclaration.parent.kind === 226 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -51817,22 +52909,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226: + case 230: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 206: - case 204: + case 210: case 208: + case 212: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 207: - case 209: + case 211: + case 213: 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 === 224) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -51854,62 +52946,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 !== 198 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 170) { + if (bindingPattern.parent.kind === 174) { 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 !== 173 && node.kind !== 172); + var elements = node.kind === 175 ? 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 !== 198 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 188 ? node.parent : node); + return textSpan(node.parent.kind === 192 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225: + case 229: 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 226: 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 232: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227: + case 231: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 225: - case 222: + case 229: + case 226: return textSpan(node); - case 200: + case 204: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 252: + case 256: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228: + case 232: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168: + case 172: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51922,7 +53014,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169: + case 173: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51934,33 +53026,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 205 || - node.parent.kind === 175 || - node.parent.kind === 176) { + if (node.parent.kind === 209 || + node.parent.kind === 179 || + node.parent.kind === 180) { return spanInPreviousNode(node); } - if (node.parent.kind === 179) { + if (node.parent.kind === 183) { 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 184: + case 225: + case 185: case 149: - case 206: - case 205: - case 207: + case 148: + case 151: + case 152: + case 150: + case 210: case 209: - case 175: - case 176: + case 211: + case 213: case 179: + case 180: + case 183: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -51968,26 +53060,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 || - node.parent.kind === 143) { + node.parent.kind === 257 || + node.parent.kind === 144) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 178) { + if (node.parent.kind === 182) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205) { + if (node.parent.kind === 209) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 213) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -52000,7 +53092,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; @@ -52018,7 +53110,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 132 || + keyword2 === 133 || keyword2 === 122 || keyword2 === 114) { return true; @@ -52134,10 +53226,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; } @@ -52292,7 +53384,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 139; + return token >= 71 && token <= 140; } function classFromKind(token) { if (isKeyword(token)) { @@ -52338,10 +53430,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { + case 230: case 226: - case 222: - case 223: - case 221: + case 227: + case 225: cancellationToken.throwIfCancellationRequested(); } } @@ -52385,7 +53477,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 && + return declaration.kind === 230 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -52457,8 +53549,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 }; @@ -52526,16 +53618,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 275: + case 280: processJSDocParameterTag(tag); break; - case 278: + case 283: processJSDocTemplateTag(tag); break; - case 277: + case 282: processElement(tag.typeExpression); break; - case 276: + case 281: processElement(tag.typeExpression); break; } @@ -52616,22 +53708,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244: + case 248: if (token.parent.tagName === token) { return 19; } break; - case 245: + case 249: if (token.parent.tagName === token) { return 20; } break; - case 243: + case 247: if (token.parent.tagName === token) { return 21; } break; - case 246: + case 250: if (token.parent.name === token) { return 22; } @@ -52651,17 +53743,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 === 223 || + token.parent.kind === 147 || + token.parent.kind === 144 || + token.parent.kind === 250) { return 5; } } - if (token.parent.kind === 188 || - token.parent.kind === 186 || - token.parent.kind === 187 || - token.parent.kind === 189) { + if (token.parent.kind === 192 || + token.parent.kind === 190 || + token.parent.kind === 191 || + token.parent.kind === 193) { return 5; } } @@ -52671,7 +53763,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 246 ? 24 : 6; + return token.parent.kind === 250 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -52685,32 +53777,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 222: + case 226: if (token.parent.name === token) { return 11; } return; - case 142: + case 143: if (token.parent.name === token) { return 15; } return; - case 223: + case 227: if (token.parent.name === token) { return 13; } return; - case 225: + case 229: if (token.parent.name === token) { return 12; } return; - case 226: + case 230: if (token.parent.name === token) { return 14; } return; - case 143: + case 144: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -52765,7 +53857,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 245) { + location.parent && location.parent.kind === 249) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -52787,13 +53879,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { - if (nameTable[name_46] === position) { + for (var name_43 in nameTable) { + if (nameTable[name_43] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), 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, @@ -52843,15 +53935,15 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 253 && - node.parent.parent.kind === 172 && + if (node.parent.kind === 257 && + node.parent.parent.kind === 176 && 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 === 235 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -52914,7 +54006,7 @@ var ts; if (!type) { return; } - if (type.flags & 524288) { + if (type.flags & 65536) { ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); } else { @@ -53215,11 +54307,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_16; + currentDir = parent_14; } else { break; @@ -53351,9 +54443,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277: - case 275: - case 276: + case 282: + case 280: + case 281: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -53388,13 +54480,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_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_17.kind === 173) { + if (parent_15.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140) { + else if (parent_15.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -53407,7 +54499,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 249) { isStartingCloseTag = true; location = contextToken; } @@ -53452,7 +54544,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 === 177) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -53477,7 +54569,7 @@ var ts; symbols.push(symbol); } } - if (isJavaScriptFile && type.flags & 524288) { + if (isJavaScriptFile && type.flags & 65536) { var unionType = type; for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { var elementType = _c[_b]; @@ -53498,7 +54590,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { + if ((jsxContainer.kind === 247) || (jsxContainer.kind === 248)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -53519,9 +54611,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 256 || - scopeNode.kind === 190 || - scopeNode.kind === 248 || + scopeNode.kind === 261 || + scopeNode.kind === 194 || + scopeNode.kind === 252 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -53549,11 +54641,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 244) { + if (contextToken.parent.kind === 248) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 242; + if (contextToken.parent.kind === 249 || contextToken.parent.kind === 247) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 246; } } return false; @@ -53563,40 +54655,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; + return containingNodeKind === 179 + || containingNodeKind === 150 + || containingNodeKind === 180 + || containingNodeKind === 175 + || containingNodeKind === 192 + || containingNodeKind === 158; case 18: - return containingNodeKind === 175 - || containingNodeKind === 149 - || containingNodeKind === 176 - || containingNodeKind === 179 - || containingNodeKind === 165; + return containingNodeKind === 179 + || containingNodeKind === 150 + || containingNodeKind === 180 + || containingNodeKind === 183 + || containingNodeKind === 166; case 20: - return containingNodeKind === 171 - || containingNodeKind === 154 - || containingNodeKind === 141; - case 126: + return containingNodeKind === 175 + || containingNodeKind === 155 + || containingNodeKind === 142; case 127: + case 128: return true; case 22: - return containingNodeKind === 226; + return containingNodeKind === 230; case 16: - return containingNodeKind === 222; + return containingNodeKind === 226; case 57: - return containingNodeKind === 219 - || containingNodeKind === 188; + return containingNodeKind === 223 + || containingNodeKind === 192; case 13: - return containingNodeKind === 190; + return containingNodeKind === 194; case 14: - return containingNodeKind === 198; + return containingNodeKind === 202; case 113: case 111: case 112: - return containingNodeKind === 146; + return containingNodeKind === 147; } switch (previousToken.getText()) { case "public": @@ -53627,22 +54719,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172) { + if (objectLikeContainer.kind === 176) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168) { + else if (objectLikeContainer.kind === 172) { 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); } } @@ -53668,9 +54760,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 234 ? - 231 : - 237; + var declarationKind = namedImportsOrExports.kind === 238 ? + 235 : + 241; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -53691,9 +54783,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_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { + return parent_16; } break; } @@ -53706,8 +54798,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 234: case 238: + case 242: return contextToken.parent; } } @@ -53716,34 +54808,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_17 = 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 250: + case 251: + if (parent_17 && (parent_17.kind === 247 || parent_17.kind === 248)) { + return parent_17; } - else if (parent_19.kind === 246) { - return parent_19.parent; + else if (parent_17.kind === 250) { + return parent_17.parent; } break; case 9: - if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { - return parent_19.parent; + if (parent_17 && ((parent_17.kind === 250) || (parent_17.kind === 251))) { + return parent_17.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_17 && + parent_17.kind === 252 && + parent_17.parent && + (parent_17.parent.kind === 250)) { + return parent_17.parent.parent; } - if (parent_19 && parent_19.kind === 247) { - return parent_19.parent; + if (parent_17 && parent_17.kind === 251) { + return parent_17.parent; } break; } @@ -53752,16 +54844,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 180: - case 181: - case 221: + case 184: + case 185: + case 225: + case 149: case 148: - case 147: - case 150: case 151: case 152: case 153: case 154: + case 155: return true; } return false; @@ -53770,66 +54862,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 219 || - containingNodeKind === 220 || - containingNodeKind === 201 || - containingNodeKind === 225 || + return containingNodeKind === 223 || + containingNodeKind === 224 || + containingNodeKind === 205 || + containingNodeKind === 229 || isFunction(containingNodeKind) || - containingNodeKind === 222 || - containingNodeKind === 193 || - containingNodeKind === 223 || - containingNodeKind === 169 || - containingNodeKind === 224; + containingNodeKind === 226 || + containingNodeKind === 197 || + containingNodeKind === 227 || + containingNodeKind === 173 || + containingNodeKind === 228; case 22: - return containingNodeKind === 169; + return containingNodeKind === 173; case 55: - return containingNodeKind === 170; + return containingNodeKind === 174; case 20: - return containingNodeKind === 169; + return containingNodeKind === 173; case 18: - return containingNodeKind === 252 || + return containingNodeKind === 256 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 225 || - containingNodeKind === 223 || - containingNodeKind === 160; + return containingNodeKind === 229 || + containingNodeKind === 227 || + 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 === 227 || + contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 222 || - containingNodeKind === 193 || - containingNodeKind === 223 || - containingNodeKind === 224 || + return containingNodeKind === 226 || + containingNodeKind === 197 || + containingNodeKind === 227 || + containingNodeKind === 228 || 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 === 173); case 113: case 111: case 112: - return containingNodeKind === 143; + return containingNodeKind === 144; case 117: - return containingNodeKind === 235 || - containingNodeKind === 239 || - containingNodeKind === 233; + return containingNodeKind === 239 || + containingNodeKind === 243 || + containingNodeKind === 237; 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()) { @@ -53866,8 +54958,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_44 = element.propertyName || element.name; + existingImportsOrExports[name_44.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -53881,17 +54973,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 !== 257 && + m.kind !== 258 && + m.kind !== 174 && + 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 === 174 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -53910,7 +55004,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246) { + if (attr.kind === 250) { seenNames[attr.name.text] = true; } } @@ -53943,7 +55037,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, @@ -54007,7 +55101,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)) { @@ -54059,75 +55153,75 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 204)) { + if (hasKind(node.parent, 208)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 212)) { + if (hasKind(node.parent, 216)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 220)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 217)) { + if (hasKind(parent(parent(node)), 221)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 217)) { + if (hasKind(parent(node), 221)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 214)) { + if (hasKind(node.parent, 218)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 214)) { + if (hasKind(parent(parent(parent(node))), 218)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { + if (hasKind(node.parent, 215) || hasKind(node.parent, 214)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 207) || - hasKind(node.parent, 208) || - hasKind(node.parent, 209)) { + if (hasKind(node.parent, 211) || + hasKind(node.parent, 212) || + hasKind(node.parent, 213)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { + if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { 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 === 205)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -54139,10 +55233,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216) { + if (node.kind === 220) { statementAccumulator.push(node); } - else if (node.kind === 217) { + else if (node.kind === 221) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -54162,17 +55256,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_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 261) { + return parent_18; } - if (parent_20.kind === 217) { - var tryStatement = parent_20; + if (parent_18.kind === 221) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_18; } return undefined; } @@ -54181,7 +55275,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 || node.kind === 210) { + if (node.kind === 215 || node.kind === 214) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -54196,15 +55290,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 218: + if (statement.kind === 214) { continue; } - case 207: - case 208: + case 211: + case 212: + case 213: + case 210: case 209: - case 206: - case 205: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -54221,24 +55315,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 === 226 || + container.kind === 197 || + (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 222 || container.kind === 193)) { + if (!(container.kind === 226 || container.kind === 197)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 227 || container.kind === 256)) { + if (!(container.kind === 231 || container.kind === 261)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 222 || declaration.kind === 222)) { + if (!(container.kind === 226 || declaration.kind === 226)) { return undefined; } } @@ -54249,8 +55343,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227: - case 256: + case 231: + case 261: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -54258,15 +55352,15 @@ var ts; nodes = container.statements; } break; - case 149: + case 150: nodes = container.parameters.concat(container.parent.members); break; - case 222: - case 193: + case 226: + case 197: 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); @@ -54319,13 +55413,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); }); } } } @@ -54342,7 +55436,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 205) { + if (loopNode.kind === 209) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -54363,13 +55457,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 207: - case 208: + case 211: + case 212: + case 213: case 209: - case 205: - case 206: + case 210: return getLoopBreakContinueOccurrences(owner); - case 214: + case 218: return getSwitchCaseDefaultOccurrences(owner); } } @@ -54419,7 +55513,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 200))) { + if (!(func && hasKind(func.body, 204))) { return undefined; } var keywords = []; @@ -54433,7 +55527,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 208) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -54444,7 +55538,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204)) { + if (!hasKind(ifStatement.elseStatement, 208)) { break; } ifStatement = ifStatement.elseStatement; @@ -54479,7 +55573,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 === 219; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -54683,16 +55777,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 232); + var defaultImport = ts.getDeclarationOfKind(symbol, 236); 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 === 239 || + declaration.kind === 243) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 235 ? + return importOrExportSpecifier.kind === 239 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -54707,14 +55801,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 174); return bindingElement && - bindingElement.parent.kind === 168 && + bindingElement.parent.kind === 172 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 174); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -54730,13 +55824,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { + if (valueDeclaration && (valueDeclaration.kind === 184 || valueDeclaration.kind === 197)) { 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, 226); } } if (symbol.flags & 8388608) { @@ -54760,7 +55854,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 256 && !ts.isExternalModule(container)) { + if (container.kind === 261 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -54782,8 +55876,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); @@ -54893,7 +55987,7 @@ var ts; if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { return [localParentType.symbol]; } - else if (localParentType.flags & 1572864) { + else if (localParentType.flags & 196608) { return getSymbolsForClassAndInterfaceComponents(localParentType); } } @@ -54927,14 +56021,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) { @@ -54956,7 +56050,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) { @@ -54997,7 +56091,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 254) { + if (refNode.parent.kind === 258) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -55007,24 +56101,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_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.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_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 204) { + ts.forEachReturnStatement(parent_19.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_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -55041,7 +56135,7 @@ var ts; if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { result.push(componentType.symbol); } - if (componentType.getFlags() & 1572864) { + if (componentType.getFlags() & 196608) { getSymbolsForClassAndInterfaceComponents(componentType, result); } } @@ -55059,26 +56153,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 - && node.parent.kind === 251 + if (node.kind === 199 + && node.parent.kind === 255 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 70 || node.kind === 173) { + else if (node.kind === 70 || node.kind === 177) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 179) { + if (node.kind === 183) { return isImplementationExpression(node.expression); } - return node.kind === 181 || - node.kind === 180 || - node.kind === 172 || - node.kind === 193 || - node.kind === 171; + return node.kind === 185 || + node.kind === 184 || + node.kind === 176 || + node.kind === 197 || + node.kind === 175; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -55107,7 +56201,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223) { + else if (declaration.kind === 227) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -55134,13 +56228,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; @@ -55168,32 +56262,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 261: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 221: - case 180: + case 225: + case 184: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256) { + if (searchSpaceNode.kind === 261) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -55227,26 +56321,26 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 180: - case 221: + case 184: + case 225: 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 197: + case 226: 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 261: + if (container.kind === 261 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -55285,8 +56379,8 @@ var ts; if (!node_2 || node_2.kind !== 9) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { references.push(getReferenceEntryFromNode(node_2)); } } @@ -55295,7 +56389,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 258) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -55314,7 +56408,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)); } @@ -55345,7 +56439,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223) { + else if (declaration.kind === 227) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -55408,7 +56502,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; @@ -55427,7 +56521,7 @@ var ts; if (symbol_2) { result_4.push(symbol_2); } - if (contextualType.flags & 524288) { + if (contextualType.flags & 65536) { ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -55477,7 +56571,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219) { + else if (node.kind === 223) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -55487,18 +56581,18 @@ var ts; } else { switch (node.kind) { - case 222: - case 193: - case 225: case 226: + case 197: + case 229: + case 230: 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 === 205) { + ts.Debug.assert(node.parent.kind === 224); return node.parent.parent; } } @@ -55536,10 +56630,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 || parent.kind === 186) { + if (parent.kind === 191 || parent.kind === 190) { return true; } - else if (parent.kind === 188 && parent.left === node) { + else if (parent.kind === 192 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -55558,7 +56652,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: @@ -55568,11 +56662,11 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 253: - case 254: - case 148: - case 150: + case 257: + case 258: + case 149: case 151: + case 152: return true; } return false; @@ -55631,11 +56725,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 === 239 && declaration.parent && declaration.parent.kind === 238))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 254) { + if (node.parent.kind === 258) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -55662,7 +56756,7 @@ var ts; if (!type) { return undefined; } - if (type.flags & 524288 && !(type.flags & 16)) { + if (type.flags & 65536 && !(type.flags & 16)) { var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { @@ -55712,8 +56806,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 === 225 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -55789,7 +56883,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 254) { + if (node.parent.kind === 258) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -55914,16 +57008,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 221: - case 148: + case 225: case 149: - case 222: - case 201: - break findOwner; - case 256: - return undefined; + case 150: case 226: - if (commentOwner.parent.kind === 226) { + case 205: + break findOwner; + case 261: + return undefined; + case 230: + if (commentOwner.parent.kind === 230) { return undefined; } break findOwner; @@ -55957,7 +57051,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201) { + if (commentOwner.kind === 205) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -55967,17 +57061,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 179) { + while (rightHandSide.kind === 183) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180: - case 181: + case 184: + case 185: return rightHandSide.parameters; - case 193: + case 197: 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; } } @@ -55988,147 +57082,6 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { - var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typingOptions.include); - exclude = typingOptions.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - for (var name_48 in packageNameToTypingLocation) { - if (name_48 in inferredTypings && !inferredTypings[name_48]) { - inferredTypings[name_48] = packageNameToTypingLocation[name_48]; - } - } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - filesToWatch.push(jsonPath); - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { @@ -56141,10 +57094,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; } @@ -56155,21 +57108,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 === 236 || decl.kind === 239 || decl.kind === 234) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -56210,7 +57163,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 { @@ -56227,7 +57180,7 @@ var ts; } return true; } - if (expression.kind === 173) { + if (expression.kind === 177) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -56238,7 +57191,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; } @@ -56370,7 +57323,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++) { @@ -56380,28 +57333,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 236: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 237) { addLeafNode(namedBindings); } else { @@ -56412,12 +57365,12 @@ var ts; } } break; - case 170: - case 219: + case 174: + case 223: 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); @@ -56426,12 +57379,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181: - case 221: - case 180: + case 185: + case 225: + case 184: addNodeWithRecursiveChild(node, node.body); break; - case 225: + case 229: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -56441,9 +57394,9 @@ var ts; } endNode(); break; - case 222: - case 193: - case 223: + case 226: + case 197: + case 227: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -56451,21 +57404,21 @@ var ts; } endNode(); break; - case 226: + case 230: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 239: - case 230: - case 154: - case 152: + case 243: + case 234: + case 155: case 153: - case 224: + case 154: + case 228: addLeafNode(node); break; default: ts.forEach(node.jsDocComments, function (jsDocComment) { ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279) { + if (tag.kind === 284) { addLeafNode(tag); } }); @@ -56513,12 +57466,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 !== 230 || 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 !== 230) { return true; } return areSameModule(a.body, b.body); @@ -56569,7 +57522,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 226) { + if (node.kind === 230) { return getModuleName(node); } var decl = node; @@ -56577,18 +57530,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180: - case 181: - case 193: + case 184: + case 185: + case 197: return getFunctionOrClassName(node); - case 279: + case 284: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226) { + if (node.kind === 230) { return getModuleName(node); } var name = node.name; @@ -56599,29 +57552,29 @@ var ts; } } switch (node.kind) { - case 256: + case 261: 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 185: + case 225: + case 184: + case 226: + case 197: 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 284: return getJSDocTypedefTagName(node); default: return ""; @@ -56633,7 +57586,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 205) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -56661,24 +57614,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 222: - case 193: - case 225: - case 223: case 226: - case 256: - case 224: - case 279: + case 197: + case 229: + case 227: + case 230: + case 261: + case 228: + case 284: return true; - case 149: - case 148: case 150: + case 149: case 151: - case 219: + case 152: + case 223: return hasSomeImportantChild(item); - case 181: - case 221: - case 180: + case 185: + case 225: + case 184: return isTopLevelFunctionDeclaration(item); default: return false; @@ -56688,10 +57641,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227: - case 256: - case 148: + case 231: + case 261: case 149: + case 150: return true; default: return hasSomeImportantChild(item); @@ -56700,7 +57653,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 219 && childKind !== 170; + return childKind !== 223 && childKind !== 174; }); } } @@ -56755,20 +57708,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 230) { 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 === 230 ? 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 === 261 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -56776,14 +57729,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 === 223) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 && + else if (node.parent.kind === 192 && node.parent.operatorToken.kind === 57) { - return nodeText(node.parent.left); + return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 && node.parent.name) { + else if (node.parent.kind === 257 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -56794,8 +57747,9 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 || node.kind === 181 || node.kind === 193; + return node.kind === 184 || node.kind === 185 || node.kind === 197; } + var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); var ts; @@ -56866,7 +57820,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181; + return ts.isFunctionBlock(node) && node.parent.kind !== 185; } var depth = 0; var maxDepth = 20; @@ -56878,26 +57832,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200: + case 204: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_20 = 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_20.kind === 209 || + parent_20.kind === 212 || + parent_20.kind === 213 || + parent_20.kind === 211 || + parent_20.kind === 208 || + parent_20.kind === 210 || + parent_20.kind === 217 || + parent_20.kind === 256) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217) { - var tryStatement = parent_22; + if (parent_20.kind === 221) { + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -56917,23 +57871,23 @@ var ts; }); break; } - case 227: { + case 231: { 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 227: + case 229: + case 176: + case 232: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 171: + case 175: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -56951,13 +57905,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, @@ -57178,7 +58132,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); @@ -57188,7 +58142,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); @@ -57424,7 +58378,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(); @@ -57445,7 +58399,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57471,7 +58425,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57485,7 +58439,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(); @@ -57511,7 +58465,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57521,7 +58475,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -57545,7 +58499,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(); @@ -57739,12 +58693,6 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; - (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; function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -57770,14 +58718,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175) { + if (argumentInfo.invocation.kind !== 179) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 173 + : expression.kind === 177 ? expression.name : undefined; if (!name || !name.text) { @@ -57806,7 +58754,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 175 || node.parent.kind === 176) { + if (node.parent.kind === 179 || node.parent.kind === 180) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -57838,23 +58786,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 177) { + else if (node.kind === 12 && node.parent.kind === 181) { 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 === 181) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 194); 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 === 202 && node.parent.parent.parent.kind === 181) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 194); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -57918,7 +58866,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 190) { + if (template.kind === 194) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -57927,7 +58875,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 !== 261; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -57977,7 +58925,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; @@ -57988,6 +58938,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); }); @@ -58002,7 +58953,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], @@ -58056,7 +59007,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 193) ? + return ts.getDeclarationOfKind(symbol, 197) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -58156,14 +59107,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 === 177) { 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 === 179 || location.kind === 180) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -58175,7 +59126,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpression.kind === 180 || 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; @@ -58211,7 +59162,7 @@ var ts; displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 2097152) && type.symbol) { + if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); } addSignatureDisplayParts(signature, allSignatures, 8); @@ -58223,21 +59174,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); @@ -58246,7 +59197,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193)) { + if (ts.getDeclarationOfKind(symbol, 197)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -58265,7 +59216,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); @@ -58286,9 +59237,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226); + var declaration = ts.getDeclarationOfKind(symbol, 230); 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); } @@ -58299,31 +59250,31 @@ var ts; displayParts.push(ts.punctuationPart(19)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91)); - displayParts.push(ts.spacePart()); if (symbol.parent) { + addInPrefix(); addFullSymbolName(symbol.parent, enclosingDeclaration); 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)) { + addInPrefix(); 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)); + else if (declaration.kind === 228) { + addInPrefix(); + displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -58334,7 +59285,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255) { + if (declaration.kind === 260) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -58346,10 +59297,10 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229) { + if (symbol.declarations[0].kind === 233) { 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)); @@ -58357,13 +59308,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230) { + if (declaration.kind === 234) { 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)); @@ -58425,10 +59376,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 === 261; })) { 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 !== 192) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -58449,6 +59400,11 @@ var ts; displayParts.push(ts.lineBreakPart()); } } + function addInPrefix() { + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(91)); + displayParts.push(ts.spacePart()); + } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); ts.addRange(displayParts, fullSymbolDisplayParts); @@ -58503,14 +59459,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 180) { + if (declaration.kind === 184) { return true; } - if (declaration.kind !== 219 && declaration.kind !== 221) { + if (declaration.kind !== 223 && declaration.kind !== 225) { 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_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { + if (parent_21.kind === 261 || parent_21.kind === 231) { return false; } } @@ -58594,7 +59550,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -58610,7 +59566,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_4(opt); } return options; } @@ -58619,18 +59575,9 @@ 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; - var ScanAction; - (function (ScanAction) { - ScanAction[ScanAction["Scan"] = 0] = "Scan"; - ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; - ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; - ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; - ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; - ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; - })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; @@ -58710,10 +59657,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 246: - case 244: - case 245: - case 243: + case 250: + case 248: + case 249: + case 247: return node.kind === 70; } } @@ -58924,20 +59871,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var formatting; - (function (formatting) { - (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; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var formatting; (function (formatting) { @@ -58959,19 +59892,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var formatting; - (function (formatting) { - (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; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var formatting; (function (formatting) { @@ -59002,17 +59922,6 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var formatting; - (function (formatting) { - (function (RuleFlags) { - RuleFlags[RuleFlags["None"] = 0] = "None"; - RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; - })(formatting.RuleFlags || (formatting.RuleFlags = {})); - var RuleFlags = formatting.RuleFlags; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var formatting; (function (formatting) { @@ -59126,13 +60035,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)); @@ -59146,7 +60055,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)); @@ -59251,43 +60160,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 === 211; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 188: - case 189: - case 196: + case 192: + case 193: + case 200: + case 243: case 239: - case 235: - case 155: - case 163: + case 156: case 164: + case 165: return true; - case 170: - case 224: - case 230: - case 219: - case 143: - case 255: + case 174: + case 228: + case 234: + case 223: + case 144: + case 260: + case 147: case 146: - case 145: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 208: + case 212: return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; - case 209: - return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; + case 213: + return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; }; @@ -59295,7 +60204,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189; + return context.contextNode.kind === 193; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -59320,90 +60229,90 @@ var ts; return true; } switch (node.kind) { - case 200: - case 228: - case 172: - case 227: + case 204: + case 232: + case 176: + case 231: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221: + case 225: + case 149: case 148: - case 147: - case 150: case 151: case 152: - case 180: - case 149: - case 181: - case 223: + case 153: + case 184: + case 150: + case 185: + case 227: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 || context.contextNode.kind === 180; + return context.contextNode.kind === 225 || context.contextNode.kind === 184; }; 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 226: - case 237: + case 197: + case 227: + case 229: + case 161: + case 230: + case 241: + case 242: + case 235: case 238: - case 231: - case 234: 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 230: + case 229: + case 204: + case 256: + case 231: + case 218: 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 218: + case 211: + case 212: case 213: - case 252: + case 210: + case 221: + case 209: + case 217: + case 256: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172; + return context.contextNode.kind === 176; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 175; + return context.contextNode.kind === 179; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 180; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -59415,25 +60324,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 185; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 242; + return context.contextNode.kind !== 246; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248; + return context.contextNode.kind === 252; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246; + return context.nextTokenParent.kind === 250; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246; + return context.contextNode.kind === 250; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243; + return context.contextNode.kind === 247; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -59448,41 +60357,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 === 224 && 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 === 230; }; 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 181: + case 157: + case 182: + case 226: + case 197: + case 227: + case 225: + case 184: + case 185: + case 149: case 148: - case 147: - case 152: case 153: - case 175: - case 176: - case 195: + case 154: + case 179: + case 180: + case 199: return true; default: return false; @@ -59493,13 +60402,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178; + return context.contextNode.kind === 182; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 188; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 195 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -59521,7 +60430,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); @@ -59534,7 +60443,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; }; @@ -59571,6 +60480,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"; @@ -59578,8 +60488,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; @@ -59698,7 +60607,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; @@ -59742,9 +60651,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]); @@ -59752,7 +60661,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 = {})); @@ -59888,10 +60797,6 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var Constants; - (function (Constants) { - Constants[Constants["Unknown"] = -1] = "Unknown"; - })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -59964,17 +60869,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 222: - case 223: - return ts.rangeContainsRange(parent.members, node); case 226: - var body = parent.body; - return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); - case 256: - case 200: case 227: + return ts.rangeContainsRange(parent.members, node); + case 230: + var body = parent.body; + return body && body.kind === 231 && ts.rangeContainsRange(body.statements, node); + case 261: + case 204: + case 231: return ts.rangeContainsRange(parent.statements, node); - case 252: + case 256: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -60130,18 +61035,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 226: return 74; + case 227: return 108; + case 225: return 88; + case 229: return 229; + 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; } } @@ -60257,11 +61162,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 === 175 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -60565,12 +61470,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 150: + case 225: + case 184: case 149: - case 221: - case 180: case 148: - case 147: - case 181: + case 185: if (node.typeParameters === list) { return 26; } @@ -60578,8 +61483,8 @@ var ts; return 18; } break; - case 175: - case 176: + case 179: + case 180: if (node.typeArguments === list) { return 26; } @@ -60587,7 +61492,7 @@ var ts; return 18; } break; - case 156: + case 157: if (node.typeArguments === list) { return 26; } @@ -60660,10 +61565,6 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { - var Value; - (function (Value) { - Value[Value["Unknown"] = -1] = "Unknown"; - })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -60692,7 +61593,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 !== 192) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -60794,7 +61695,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 === 261 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -60818,7 +61719,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 === 208 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -60830,23 +61731,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 176: return node.parent.properties; - case 171: + case 175: return node.parent.elements; - case 221: - case 180: - case 181: + case 225: + case 184: + case 185: + 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())) { @@ -60857,8 +61758,8 @@ var ts; } break; } - case 176: - case 175: { + case 180: + case 179: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -60886,8 +61787,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 === 179 || + node.parent.kind === 180) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -60905,10 +61806,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175: - case 176: - case 173: - case 174: + case 179: + case 180: + case 177: + case 178: node = node.expression; break; default: @@ -60962,48 +61863,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 203: - case 222: - case 193: - case 223: - case 225: - case 224: - case 171: - case 200: + case 207: + case 226: + case 197: case 227: - case 172: - case 160: - case 162: + case 229: case 228: - case 250: - case 249: - case 179: - case 173: case 175: + case 204: + case 231: 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 161: + case 163: + case 232: + case 254: + case 253: + case 183: case 177: - case 185: + case 179: + case 180: + case 205: + case 223: + case 240: + case 216: + case 193: + case 173: + case 172: + case 248: + case 247: + case 252: + case 148: + case 153: + case 154: + case 144: + case 158: + case 159: + case 166: + case 181: + case 189: + case 242: case 238: - case 234: + case 243: case 239: - case 235: return true; } return false; @@ -61011,27 +61912,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 207: - case 204: - case 221: - case 180: - case 148: - case 181: + case 210: + case 212: + case 213: + case 211: + case 208: + case 225: + case 184: case 149: + case 185: 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 !== 204; + case 241: + return childKind !== 242; + case 235: + return childKind !== 236 || + (child.namedBindings && child.namedBindings.kind !== 238); + case 246: + return childKind !== 249; } return indentByDefault; } @@ -61112,7 +62013,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 175) { + if (superCall.expression && superCall.expression.kind == 179) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -61136,7 +62037,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 && ts.isSuperCall(n.expression)) { + if (n.kind === 207 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -61152,7 +62053,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; @@ -61164,7 +62065,6 @@ var ts; this.end = end; this.flags = 0; this.transformFlags = undefined; - this.excludeTransformFlags = undefined; this.parent = undefined; this.kind = kind; } @@ -61211,11 +62111,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286, nodes.pos, nodes.end, this); + var list = createNode(291, 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); } @@ -61230,11 +62130,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 >= 278 && this.kind <= 290; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -61288,7 +62188,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); @@ -61296,7 +62196,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; }()); @@ -61423,7 +62323,7 @@ var ts; return this.checker.getIndexTypeOfType(this, 1); }; TypeObject.prototype.getBaseTypes = function () { - return this.flags & (32768 | 65536) + return this.flags & 32768 && this.objectFlags & (1 | 2) ? this.checker.getBaseTypes(this) : undefined; }; @@ -61498,9 +62398,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 === 177) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -61520,10 +62420,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221: - case 180: + case 225: + case 184: + case 149: case 148: - case 147: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -61540,30 +62440,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 222: - case 193: - case 223: - case 224: - case 225: case 226: + case 197: + case 227: + case 228: + case 229: case 230: + case 234: + case 243: case 239: - case 235: - case 230: - case 232: - case 233: - case 150: + case 234: + case 236: + case 237: 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 223: + case 174: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -61572,24 +62472,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255: + case 260: + case 147: case 146: - case 145: addDeclaration(node); break; - case 237: + case 241: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 231: + case 235: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 237) { addDeclaration(importClause.namedBindings); } else { @@ -61735,7 +62635,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); @@ -61888,7 +62788,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function () { }, + writeFile: ts.noop, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -62031,10 +62931,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 173: - case 140: + case 177: + case 141: case 98: - case 166: + case 167: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -62163,15 +63063,15 @@ var ts; return; } switch (node.kind) { - case 173: - case 140: + case 177: + case 141: case 9: case 85: case 100: case 94: case 96: case 98: - case 166: + case 167: case 70: break; default: @@ -62183,7 +63083,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 226 && + if (nodeForStartPos.parent.parent.kind === 230 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -62479,7 +63379,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 241 || + node.parent.kind === 245 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -62499,7 +63399,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 && + node.parent.kind === 178 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -62514,933 +63414,6 @@ var ts; } initializeServices(); })(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - 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; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); - } - } - } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; - } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (_dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; - } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); - } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typingOptions: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; - } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typingOptions: configFile.typingOptions, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); - } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); - } - catch (err) { - logInternalError(logger, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; - } - } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } -})(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.1"; -var ts; -(function (ts) { - var server; - (function (server) { - (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; - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typingOptions, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(), - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function throwLanguageServiceIsDisabledError() { - throw new Error("LanguageService is disabled"); - } - server.nullLanguageService = { - cleanupSemanticCache: throwLanguageServiceIsDisabledError, - getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, - getSemanticDiagnostics: throwLanguageServiceIsDisabledError, - getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, - getSyntacticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, - getSemanticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, - getCompletionsAtPosition: throwLanguageServiceIsDisabledError, - findReferences: throwLanguageServiceIsDisabledError, - getCompletionEntryDetails: throwLanguageServiceIsDisabledError, - getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, - findRenameLocations: throwLanguageServiceIsDisabledError, - getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, - getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, - getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, - getSignatureHelpItems: throwLanguageServiceIsDisabledError, - getDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getRenameInfo: throwLanguageServiceIsDisabledError, - getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getReferencesAtPosition: throwLanguageServiceIsDisabledError, - getDocumentHighlights: throwLanguageServiceIsDisabledError, - getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, - getNavigateToItems: throwLanguageServiceIsDisabledError, - getNavigationBarItems: throwLanguageServiceIsDisabledError, - getNavigationTree: throwLanguageServiceIsDisabledError, - getOutliningSpans: throwLanguageServiceIsDisabledError, - getTodoComments: throwLanguageServiceIsDisabledError, - getIndentationAtPosition: throwLanguageServiceIsDisabledError, - getFormattingEditsForRange: throwLanguageServiceIsDisabledError, - getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, - getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, - getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, - isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, - getEmitOutput: throwLanguageServiceIsDisabledError, - getProgram: throwLanguageServiceIsDisabledError, - getNonBoundSourceFile: throwLanguageServiceIsDisabledError, - dispose: throwLanguageServiceIsDisabledError, - getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, - getImplementationAtPosition: throwLanguageServiceIsDisabledError, - getSourceFile: throwLanguageServiceIsDisabledError, - getCodeFixesAtPosition: throwLanguageServiceIsDisabledError - }; - server.nullLanguageServiceHost = { - setCompilationSettings: function () { return undefined; }, - notifyFileRemoved: function () { return undefined; } - }; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -63607,55 +63580,58 @@ 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.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { + LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { + this.filesWithChangedSetOfUnresolvedImports = []; + }; + LSHost.prototype.finishRecordingFilesWithChangedResolutions = function () { + var collected = this.filesWithChangedSetOfUnresolvedImports; + this.filesWithChangedSetOfUnresolvedImports = undefined; + return collected; + }; + 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); + logChanges = false; } } ts.Debug.assert(resolution !== undefined); @@ -63663,16 +63639,30 @@ var ts; } cache.set(path, newResolutions); return resolvedModules; + function resolutionIsEqualTo(oldResolution, newResolution) { + if (oldResolution === newResolution) { + return true; + } + if (!oldResolution || !newResolution) { + return false; + } + var oldResult = getResult(oldResolution); + var newResult = getResult(newResolution); + if (oldResult === newResult) { + return true; + } + if (!oldResult || !newResult) { + return false; + } + return getResultFileName(oldResult) === getResultFileName(newResult); + } function moduleResolutionIsValid(resolution) { if (!resolution) { return false; } 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; } @@ -63690,10 +63680,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; }); + 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; }); + 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())); @@ -63745,9 +63735,11 @@ var ts; this.resolvedTypeReferenceDirectives.remove(info.path); }; LSHost.prototype.setCompilationSettings = function (opt) { + if (ts.changesAffectModuleResolution(this.compilationSettings, opt)) { + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + } this.compilationSettings = opt; - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); }; return LSHost; }()); @@ -63759,9 +63751,9 @@ var ts; var server; (function (server) { server.nullTypingsInstaller = { - enqueueInstallTypingsRequest: function () { }, - attach: function () { }, - onProjectClosed: function () { }, + enqueueInstallTypingsRequest: ts.noop, + attach: ts.noop, + onProjectClosed: ts.noop, globalTypingsCacheLocation: undefined }; var TypingsCacheEntry = (function () { @@ -63805,48 +63797,52 @@ var ts; function compilerOptionsChanged(opt1, opt2) { return opt1.allowJs != opt2.allowJs; } - function toTypingsArray(arr) { - arr.sort(); - return arr; + function unresolvedImportsChanged(imports1, imports2) { + if (imports1 === imports2) { + return false; + } + return !ts.arrayIsEqualTo(imports1, imports2); } var TypingsCache = (function () { function TypingsCache(installer) { this.installer = installer; this.perProjectCache = ts.createMap(); } - TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { + TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { var typingOptions = project.getTypingOptions(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return server.emptyArray; } var entry = this.perProjectCache[project.getProjectName()]; var result = entry ? entry.typings : server.emptyArray; - if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { + if (forceRefresh || + !entry || + typingOptionsChanged(typingOptions, entry.typingOptions) || + compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || + unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { this.perProjectCache[project.getProjectName()] = { compilerOptions: project.getCompilerOptions(), typingOptions: typingOptions, typings: result, + unresolvedImports: unresolvedImports, poisoned: true }; - this.installer.enqueueInstallTypingsRequest(project, typingOptions); + this.installer.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports); } return result; }; - TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions.enableAutoDiscovery) { - return; - } - this.installer.enqueueInstallTypingsRequest(project, typingOptions); - }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, unresolvedImports, newTypings) { this.perProjectCache[projectName] = { compilerOptions: compilerOptions, typingOptions: typingOptions, - typings: toTypingsArray(newTypings), + typings: server.toSortedReadonlyArray(newTypings), + unresolvedImports: unresolvedImports, poisoned: false }; }; + TypingsCache.prototype.deleteTypingsForProject = function (projectName) { + delete this.perProjectCache[projectName]; + }; TypingsCache.prototype.onProjectClosed = function (project) { delete this.perProjectCache[project.getProjectName()]; this.installer.onProjectClosed(project); @@ -63860,7 +63856,6 @@ var ts; (function (ts) { var server; (function (server) { - var crypto = require("crypto"); function shouldEmitFile(scriptInfo) { return !scriptInfo.hasMixedContent; } @@ -63877,16 +63872,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 !== 230 || 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); @@ -64162,12 +64155,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) { @@ -64211,6 +64204,32 @@ var ts; return counts.ts === 0 && counts.tsx === 0; } server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var UnresolvedImportsMap = (function () { + function UnresolvedImportsMap() { + this.perFileMap = ts.createFileMap(); + this.version = 0; + } + UnresolvedImportsMap.prototype.clear = function () { + this.perFileMap.clear(); + this.version = 0; + }; + UnresolvedImportsMap.prototype.getVersion = function () { + return this.version; + }; + UnresolvedImportsMap.prototype.remove = function (path) { + this.perFileMap.remove(path); + this.version++; + }; + UnresolvedImportsMap.prototype.get = function (path) { + return this.perFileMap.get(path); + }; + UnresolvedImportsMap.prototype.set = function (path, value) { + this.perFileMap.set(path, value); + this.version++; + }; + return UnresolvedImportsMap; + }()); + server.UnresolvedImportsMap = UnresolvedImportsMap; var Project = (function () { function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { this.projectKind = projectKind; @@ -64221,6 +64240,7 @@ var ts; this.compileOnSaveEnabled = compileOnSaveEnabled; this.rootFiles = []; this.rootFilesMap = ts.createFileMap(); + this.cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); this.lastReportedVersion = 0; this.projectStructureVersion = 0; this.projectStateVersion = 0; @@ -64233,6 +64253,9 @@ var ts; else if (hasExplicitListOfFiles) { this.compilerOptions.allowNonTsExtensions = true; } + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; + } if (languageServiceEnabled) { this.enableLanguageService(); } @@ -64250,6 +64273,9 @@ var ts; this.updateGraph(); return hasOneOrMoreJsAndNoTsFiles(this); }; + Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { + return this.cachedUnresolvedImportsPerFile; + }; Project.prototype.getProjectErrors = function () { return this.projectErrors; }; @@ -64356,7 +64382,7 @@ var ts; } return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; - Project.prototype.getFileNames = function () { + Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { if (!this.program) { return []; } @@ -64370,8 +64396,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) { @@ -64412,6 +64445,7 @@ var ts; if (detachFromProject === void 0) { detachFromProject = true; } this.removeRootFileIfNecessary(info); this.lsHost.notifyFileRemoved(info); + this.cachedUnresolvedImportsPerFile.remove(info.path); if (detachFromProject) { info.detachFromProject(this); } @@ -64420,12 +64454,56 @@ var ts; Project.prototype.markAsDirty = function () { this.projectStateVersion++; }; + Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, result) { + var cached = this.cachedUnresolvedImportsPerFile.get(file.path); + if (cached) { + for (var _i = 0, cached_1 = cached; _i < cached_1.length; _i++) { + var f = cached_1[_i]; + result.push(f); + } + return; + } + var unresolvedImports; + if (file.resolvedModules) { + 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); + } + if (i !== -1) { + trimmed = trimmed.substr(0, i); + } + (unresolvedImports || (unresolvedImports = [])).push(trimmed); + result.push(trimmed); + } + } + } + this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); + }; Project.prototype.updateGraph = function () { if (!this.languageServiceEnabled) { return true; } + this.lsHost.startRecordingFilesWithChangedResolutions(); var hasChanges = this.updateGraphWorker(); - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); + var changedFiles = this.lsHost.finishRecordingFilesWithChangedResolutions() || server.emptyArray; + for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { + var file = changedFiles_1[_i]; + this.cachedUnresolvedImportsPerFile.remove(file); + } + var unresolvedImports; + if (hasChanges || changedFiles.length) { + var result = []; + for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { + var sourceFile = _b[_a]; + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = server.toSortedReadonlyArray(result); + } + unresolvedImports = this.lastCachedUnresolvedImportsList; + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); if (this.setTypings(cachedTypings)) { hasChanges = this.updateGraphWorker() || hasChanges; } @@ -64498,6 +64576,10 @@ var ts; compilerOptions.allowJs = true; } compilerOptions.allowNonTsExtensions = true; + if (ts.changesAffectModuleResolution(this.compilerOptions, compilerOptions)) { + this.cachedUnresolvedImportsPerFile.clear(); + this.lastCachedUnresolvedImportsList = undefined; + } this.compilerOptions = compilerOptions; this.lsHost.setCompilationSettings(compilerOptions); this.markAsDirty(); @@ -64606,9 +64688,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++; @@ -64938,6 +65019,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); @@ -64964,17 +65046,18 @@ var ts; return; } switch (response.kind) { - case "set": - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); - project.updateGraph(); + case server.ActionSet: + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.unresolvedImports, response.typings); break; - case "invalidate": - this.typingsCache.invalidateCachedTypingsForProject(project); + case server.ActionInvalidate: + this.typingsCache.deleteTypingsForProject(response.projectName); break; } + project.updateGraph(); }; 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]; @@ -65525,7 +65608,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(); @@ -65658,13 +65741,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_3 = 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_3(proj); + _loop_5(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -65686,8 +65769,8 @@ var ts; } } if (changedFiles) { - for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { - var file = changedFiles_1[_a]; + for (var _a = 0, changedFiles_2 = changedFiles; _a < changedFiles_2.length; _a++) { + var file = changedFiles_2[_a]; var scriptInfo = this.getScriptInfo(file.fileName); ts.Debug.assert(!!scriptInfo); for (var i = file.changes.length - 1; i >= 0; i--) { @@ -65754,7 +65837,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); @@ -66887,9 +66972,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_53 = 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_53, 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); }); @@ -67292,6 +67377,7 @@ var ts; var server; (function (server) { var lineCollectionCapacity = 4; + var CharRangeSection; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -67299,8 +67385,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; @@ -68133,5 +68218,701 @@ var ts; server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); - -//# sourceMappingURL=tsserverlibrary.js.map +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { + return { + resolvedFileName: undefined, + failedLookupLocations: [] + }; + } + return { + resolvedFileName: resolvedFileName, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typingOptions: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typingOptions: configFile.typingOptions, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.unresolvedImports); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.2"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index ba46bcf1540..9f1423683eb 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -163,170 +163,177 @@ 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, + MappedType = 170, + LiteralType = 171, + ObjectBindingPattern = 172, + ArrayBindingPattern = 173, + BindingElement = 174, + ArrayLiteralExpression = 175, + ObjectLiteralExpression = 176, + PropertyAccessExpression = 177, + ElementAccessExpression = 178, + CallExpression = 179, + NewExpression = 180, + TaggedTemplateExpression = 181, + TypeAssertionExpression = 182, + ParenthesizedExpression = 183, + FunctionExpression = 184, + ArrowFunction = 185, + DeleteExpression = 186, + TypeOfExpression = 187, + VoidExpression = 188, + AwaitExpression = 189, + PrefixUnaryExpression = 190, + PostfixUnaryExpression = 191, + BinaryExpression = 192, + ConditionalExpression = 193, + TemplateExpression = 194, + YieldExpression = 195, + SpreadElement = 196, + ClassExpression = 197, + OmittedExpression = 198, + ExpressionWithTypeArguments = 199, + AsExpression = 200, + NonNullExpression = 201, + TemplateSpan = 202, + SemicolonClassElement = 203, + Block = 204, + VariableStatement = 205, + EmptyStatement = 206, + ExpressionStatement = 207, + IfStatement = 208, + DoStatement = 209, + WhileStatement = 210, + ForStatement = 211, + ForInStatement = 212, + ForOfStatement = 213, + ContinueStatement = 214, + BreakStatement = 215, + ReturnStatement = 216, + WithStatement = 217, + SwitchStatement = 218, + LabeledStatement = 219, + ThrowStatement = 220, + TryStatement = 221, + DebuggerStatement = 222, + VariableDeclaration = 223, + VariableDeclarationList = 224, + FunctionDeclaration = 225, + ClassDeclaration = 226, + InterfaceDeclaration = 227, + TypeAliasDeclaration = 228, + EnumDeclaration = 229, + ModuleDeclaration = 230, + ModuleBlock = 231, + CaseBlock = 232, + NamespaceExportDeclaration = 233, + ImportEqualsDeclaration = 234, + ImportDeclaration = 235, + ImportClause = 236, + NamespaceImport = 237, + NamedImports = 238, + ImportSpecifier = 239, + ExportAssignment = 240, + ExportDeclaration = 241, + NamedExports = 242, + ExportSpecifier = 243, + MissingDeclaration = 244, + ExternalModuleReference = 245, + JsxElement = 246, + JsxSelfClosingElement = 247, + JsxOpeningElement = 248, + JsxClosingElement = 249, + JsxAttribute = 250, + JsxSpreadAttribute = 251, + JsxExpression = 252, + CaseClause = 253, + DefaultClause = 254, + HeritageClause = 255, + CatchClause = 256, + PropertyAssignment = 257, + ShorthandPropertyAssignment = 258, + SpreadAssignment = 259, + EnumMember = 260, + SourceFile = 261, + JSDocTypeExpression = 262, + JSDocAllType = 263, + JSDocUnknownType = 264, + JSDocArrayType = 265, + JSDocUnionType = 266, + JSDocTupleType = 267, + JSDocNullableType = 268, + JSDocNonNullableType = 269, + JSDocRecordType = 270, + JSDocRecordMember = 271, + JSDocTypeReference = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocConstructorType = 276, + JSDocThisType = 277, + JSDocComment = 278, + JSDocTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + JSDocLiteralType = 287, + JSDocNullKeyword = 288, + JSDocUndefinedKeyword = 289, + JSDocNeverKeyword = 290, + SyntaxList = 291, + NotEmittedStatement = 292, + PartiallyEmittedExpression = 293, + MergeDeclarationMarker = 294, + EndOfDeclarationMarker = 295, + Count = 296, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -334,15 +341,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 = 171, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 139, + LastToken = 140, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -351,11 +358,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 140, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + FirstNode = 141, + FirstJSDocNode = 262, + LastJSDocNode = 287, + FirstJSDocTagNode = 278, + LastJSDocTagNode = 290, } enum NodeFlags { None = 0, @@ -373,21 +380,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 +415,7 @@ declare namespace ts { ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, + ExportDefault = 513, } enum JsxFlags { None = 0, @@ -437,12 +446,14 @@ declare namespace ts { type EqualsGreaterThanToken = Token; type EndOfFileToken = Token; type AtToken = Token; + type ReadonlyToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; + isInJSDocNamespace?: boolean; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; @@ -533,7 +544,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; @@ -547,6 +558,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; @@ -677,6 +692,23 @@ 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 MappedTypeNode extends TypeNode, Declaration { + kind: SyntaxKind.MappedType; + readonlyToken?: ReadonlyToken; + typeParameter: TypeParameterDeclaration; + questionToken?: QuestionToken; + type?: TypeNode; + } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: Expression; @@ -709,9 +741,6 @@ declare namespace ts { operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } @@ -780,6 +809,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; @@ -846,8 +886,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; } /** @@ -1141,12 +1181,16 @@ declare namespace ts { interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | LiteralExpression; - body?: ModuleBlock | NamespaceDeclaration; + body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; } interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: ModuleBlock | NamespaceDeclaration; } + interface JSDocNamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: JSDocNamespaceDeclaration | Identifier; + } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; statements: NodeArray; @@ -1318,6 +1362,7 @@ declare namespace ts { } interface JSDocTypedefTag extends JSDocTag, Declaration { kind: SyntaxKind.JSDocTypedefTag; + fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression; jsDocTypeLiteral?: JSDocTypeLiteral; @@ -1708,14 +1753,11 @@ declare namespace ts { Null = 4096, Never = 8192, TypeParameter = 16384, - Class = 32768, - Interface = 65536, - Reference = 131072, - Tuple = 262144, - Union = 524288, - Intersection = 1048576, - Anonymous = 2097152, - Instantiated = 4194304, + Object = 32768, + Union = 65536, + Intersection = 131072, + Index = 262144, + IndexedAccess = 524288, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1723,12 +1765,11 @@ declare namespace ts { NumberLike = 340, BooleanLike = 136, EnumLike = 272, - ObjectType = 2588672, - UnionOrIntersection = 1572864, - StructuredType = 4161536, - StructuredOrTypeParameter = 4177920, - Narrowable = 4178943, - NotUnionOrUnit = 2589185, + UnionOrIntersection = 196608, + StructuredType = 229376, + StructuredOrTypeParameter = 507904, + Narrowable = 1033215, + NotUnionOrUnit = 33281, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1749,8 +1790,21 @@ declare namespace ts { interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; } + enum ObjectFlags { + Class = 1, + Interface = 2, + Reference = 4, + Tuple = 8, + Anonymous = 16, + Mapped = 32, + Instantiated = 64, + ObjectLiteral = 128, + EvolvingArray = 256, + ObjectLiteralPatternWithComputedProperties = 512, + ClassOrInterface = 3, + } interface ObjectType extends Type { - isObjectLiteralPatternWithComputedProperties?: boolean; + objectFlags: ObjectFlags; } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; @@ -1778,9 +1832,21 @@ declare namespace ts { } interface IntersectionType extends UnionOrIntersectionType { } + type StructuredType = ObjectType | UnionType | IntersectionType; + interface EvolvingArrayType extends ObjectType { + elementType: Type; + finalArrayType?: Type; + } 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, @@ -1882,6 +1948,7 @@ declare namespace ts { preserveConstEnums?: boolean; project?: string; reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -1912,6 +1979,7 @@ declare namespace ts { packageNameToTypingLocation: Map; typingOptions: TypingOptions; compilerOptions: CompilerOptions; + unresolvedImports: ReadonlyArray; } enum ModuleKind { None = 0, @@ -1947,12 +2015,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; @@ -1979,12 +2049,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 { @@ -2042,7 +2145,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; @@ -2057,6 +2164,8 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; + setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout?(timeoutId: any): void; } interface FileWatcher { close(): void; @@ -2159,6 +2268,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; } @@ -2172,7 +2282,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. @@ -2188,7 +2298,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.1.0"; + const version = "2.2.0"; 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 dad603b624a..a36522ece49 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,198 @@ 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["MappedType"] = 170] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 171] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 172] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 173] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 174] = "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"] = 175] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 176] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 177] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 178] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 179] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 180] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 181] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 182] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 184] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 185] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 186] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 187] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 188] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 189] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 190] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 191] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 192] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 193] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 194] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 195] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 196] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 197] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 198] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "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"] = 204] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "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"] = 246] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "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"] = 253] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "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"] = 264] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 280] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 281] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 282] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 283] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 284] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 285] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 287] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 288] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 289] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 290] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 291] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 292] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 293] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 294] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 295] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 296] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -353,15 +361,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"] = 171] = "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 +378,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"] = 262] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 287] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 290] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; NodeFlags[NodeFlags["Let"] = 1] = "Let"; @@ -393,25 +401,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 +440,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 +450,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 +482,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 +490,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 +500,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 +515,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 +528,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 +568,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 +644,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 +668,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"; @@ -670,24 +686,19 @@ var ts; TypeFlags[TypeFlags["Null"] = 4096] = "Null"; TypeFlags[TypeFlags["Never"] = 8192] = "Never"; TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 32768] = "Class"; - TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 524288] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + 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["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -703,31 +714,44 @@ var ts; TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + 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"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "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"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(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 @@ -738,19 +762,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"; @@ -758,53 +782,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"; @@ -931,9 +956,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 @@ -942,61 +976,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"; @@ -1025,16 +1064,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; @@ -1144,12 +1184,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; @@ -1221,12 +1261,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. @@ -1244,6 +1284,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. @@ -1536,20 +1583,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); } @@ -1573,6 +1625,41 @@ var ts; return result; } ts.deduplicate = deduplicate; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function changesAffectModuleResolution(oldOptions, newOptions) { + return !oldOptions || + (oldOptions.module !== newOptions.module) || + (oldOptions.moduleResolution !== newOptions.moduleResolution) || + (oldOptions.noResolve !== newOptions.noResolve) || + (oldOptions.target !== newOptions.target) || + (oldOptions.noLib !== newOptions.noLib) || + (oldOptions.jsx !== newOptions.jsx) || + (oldOptions.allowJs !== newOptions.allowJs) || + (oldOptions.rootDir !== newOptions.rootDir) || + (oldOptions.configFilePath !== newOptions.configFilePath) || + (oldOptions.baseUrl !== newOptions.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) || + !arrayIsEqualTo(oldOptions.lib, newOptions.lib) || + !arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) || + !equalOwnProperties(oldOptions.paths, newOptions.paths); + } + ts.changesAffectModuleResolution = changesAffectModuleResolution; /** * Compacts an array, removing any falsey elements. */ @@ -1594,6 +1681,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++) { @@ -1603,15 +1715,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) { @@ -1624,26 +1760,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 @@ -1651,6 +1778,31 @@ 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; + return result; + } + ts.replaceElement = replaceElement; /** * Performs a binary search, finding the index at which 'value' occurs in 'array'. * If no such index is found, returns the 2's-complement of first index at which @@ -1658,11 +1810,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 @@ -1978,6 +2130,14 @@ var ts; return Array.isArray ? Array.isArray(value) : value instanceof Array; } ts.isArray = isArray; + /** Does nothing. */ + function noop() { } + ts.noop = noop; + /** Throws an error because a function is not implemented. */ + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; function memoize(callback) { var value; return function () { @@ -2094,6 +2254,17 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText + }; + } + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; function chainDiagnosticMessages(details, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -2541,6 +2712,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); } @@ -2581,73 +2756,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); } @@ -2721,29 +2916,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` @@ -2808,14 +3009,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])) { @@ -2874,10 +3075,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); } @@ -2912,13 +3109,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 */; @@ -3055,6 +3252,41 @@ 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) { + var ext = tryGetExtensionFromPath(path); + if (ext !== undefined) { + return ext; + } + Debug.fail("File " + path + " has unknown extension."); + } + ts.extensionFromPath = extensionFromPath; + function tryGetExtensionFromPath(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; + } + } + ts.tryGetExtensionFromPath = tryGetExtensionFromPath; })(ts || (ts = {})); /// var ts; @@ -3376,6 +3608,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, @@ -3385,7 +3618,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 { @@ -3393,7 +3626,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); } }; @@ -3410,7 +3643,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 }; @@ -3491,7 +3724,9 @@ var ts; } catch (e) { } - } + }, + setTimeout: setTimeout, + clearTimeout: clearTimeout }; return nodeSystem; } @@ -3617,7 +3852,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." }, @@ -3727,7 +3962,6 @@ var ts; Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, @@ -3845,14 +4079,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}'" }, @@ -3892,7 +4126,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" }, @@ -3930,8 +4164,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." }, @@ -3943,7 +4175,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." }, @@ -3965,9 +4197,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." }, @@ -4014,6 +4244,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." }, @@ -4037,6 +4274,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." }, @@ -4068,6 +4306,10 @@ 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." }, + An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, 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}'." }, @@ -4167,6 +4409,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." }, @@ -4250,7 +4493,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." }, @@ -4287,11 +4530,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." }, @@ -4300,7 +4548,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." }, @@ -4347,6 +4596,8 @@ var ts; Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, @@ -4354,6 +4605,8 @@ var ts; Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, 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 = {})); /// @@ -4389,7 +4642,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 */, @@ -4399,34 +4652,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 */, @@ -4434,7 +4688,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 139 /* OfKeyword */, + "of": 140 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -5984,10 +6238,13 @@ var ts; case 44 /* comma */: pos++; return token = 25 /* CommaToken */; + case 46 /* dot */: + 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 */; @@ -6112,11 +6369,11 @@ var ts; // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; } return stringWriters.pop(); @@ -6131,22 +6388,6 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; function hasResolvedModule(sourceFile, moduleNameText) { return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); } @@ -6171,7 +6412,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 */ @@ -6200,28 +6443,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 !== 261 /* SourceFile */) { node = node.parent; } return node; @@ -6229,11 +6472,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 204 /* Block */: + case 232 /* CaseBlock */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: return true; } return false; @@ -6324,18 +6567,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 === 291 /* 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 >= 262 /* FirstJSDocNode */ && node.kind <= 287 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 /* FirstJSDocTagNode */ && node.kind <= 285 /* LastJSDocTagNode */; + return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 290 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6434,25 +6677,31 @@ var ts; ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || - isCatchClauseVariableDeclaration(declaration); + isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 /* ModuleDeclaration */ && + return node && node.kind === 230 /* 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 === 230 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 /* SourceFile */ || - node.kind === 226 /* ModuleDeclaration */ || + return node.kind === 261 /* SourceFile */ || + node.kind === 230 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6468,9 +6717,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: return ts.isExternalModule(node.parent); - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6478,22 +6727,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 261 /* SourceFile */: + case 232 /* CaseBlock */: + case 256 /* CatchClause */: + case 230 /* ModuleDeclaration */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return true; - case 200 /* Block */: + case 204 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6513,13 +6762,6 @@ var ts; } } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 219 /* VariableDeclaration */ && - declaration.parent && - declaration.parent.kind === 252 /* CatchClause */; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. @@ -6527,12 +6769,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 177 /* 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); @@ -6555,7 +6827,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 === 204 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6569,7 +6841,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256 /* SourceFile */: + case 261 /* 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 @@ -6578,23 +6850,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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 229 /* EnumDeclaration */: + case 260 /* EnumMember */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 228 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6617,7 +6889,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 /* EnumDeclaration */ && isConst(node); + return node.kind === 229 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6630,11 +6902,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 179 /* 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 === 207 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6650,10 +6922,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 === 184 /* FunctionExpression */ || + node.kind === 185 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6669,39 +6941,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 <= 171 /* 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 !== 188 /* VoidExpression */; + case 199 /* 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 === 177 /* 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 === 177 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141 /* QualifiedName */: + case 177 /* 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: @@ -6710,38 +6982,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 <= 171 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 195 /* ExpressionWithTypeArguments */: + case 199 /* 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 223 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* 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 182 /* TypeAssertionExpression */: return node === parent_1.type; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6755,23 +7027,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 216 /* 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 232 /* CaseBlock */: + case 204 /* Block */: + case 208 /* IfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 217 /* WithStatement */: + case 218 /* SwitchStatement */: + case 253 /* CaseClause */: + case 254 /* DefaultClause */: + case 219 /* LabeledStatement */: + case 221 /* TryStatement */: + case 256 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -6781,18 +7053,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191 /* YieldExpression */: + case 195 /* 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 229 /* EnumDeclaration */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* 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. @@ -6800,7 +7072,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); @@ -6819,14 +7091,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 174 /* BindingElement */: + case 260 /* EnumMember */: + case 144 /* Parameter */: + case 257 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 258 /* ShorthandPropertyAssignment */: + case 223 /* VariableDeclaration */: return true; } } @@ -6834,11 +7106,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 === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6847,19 +7119,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* 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; @@ -6867,13 +7139,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: return true; } return false; @@ -6881,30 +7153,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 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: return true; - case 215 /* LabeledStatement */: + case 219 /* 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 === 204 /* 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 === 176 /* 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 === 176 /* ObjectLiteralExpression */ || + node.parent.kind === 197 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6940,7 +7212,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 @@ -6955,9 +7227,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; @@ -6968,26 +7240,26 @@ var ts; node = node.parent; } break; - case 181 /* ArrowFunction */: + case 185 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 230 /* 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 229 /* EnumDeclaration */: + case 261 /* SourceFile */: return node; } } @@ -7008,26 +7280,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* 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; @@ -7043,14 +7315,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { + if (func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 179 /* ParenthesizedExpression */) { + while (parent_2.kind === 183 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 179 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7061,32 +7333,32 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + return (kind === 177 /* PropertyAccessExpression */ || kind === 178 /* 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 272 /* JSDocTypeReference */: + return node.typeName; + case 199 /* 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 179 /* CallExpression */: + case 180 /* NewExpression */: + case 181 /* TaggedTemplateExpression */: + case 145 /* Decorator */: return true; default: return false; @@ -7094,7 +7366,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 181 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7103,25 +7375,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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 === 226 /* 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 === 226 /* 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 === 226 /* ClassDeclaration */; } return false; } @@ -7137,19 +7409,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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 === 248 /* JsxOpeningElement */ || + parent.kind === 247 /* JsxSelfClosingElement */ || + parent.kind === 249 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7163,43 +7435,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 175 /* ArrayLiteralExpression */: + case 176 /* ObjectLiteralExpression */: + case 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 181 /* TaggedTemplateExpression */: + case 200 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 201 /* NonNullExpression */: + case 183 /* ParenthesizedExpression */: + case 184 /* FunctionExpression */: + case 197 /* ClassExpression */: + case 185 /* ArrowFunction */: + case 188 /* VoidExpression */: + case 186 /* DeleteExpression */: + case 187 /* TypeOfExpression */: + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: + case 192 /* BinaryExpression */: + case 193 /* ConditionalExpression */: + case 196 /* SpreadElement */: + case 194 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* OmittedExpression */: - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 191 /* YieldExpression */: - case 185 /* AwaitExpression */: + case 198 /* OmittedExpression */: + case 246 /* JsxElement */: + case 247 /* JsxSelfClosingElement */: + case 195 /* YieldExpression */: + case 189 /* 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 @@ -7208,47 +7480,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 223 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 260 /* EnumMember */: + case 257 /* PropertyAssignment */: + case 174 /* 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 207 /* ExpressionStatement */: + case 208 /* IfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 216 /* ReturnStatement */: + case 217 /* WithStatement */: + case 218 /* SwitchStatement */: + case 253 /* CaseClause */: + case 220 /* ThrowStatement */: + case 218 /* SwitchStatement */: return parent_3.expression === node; - case 207 /* ForStatement */: + case 211 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || forInStatement.expression === node; - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: return node === parent_3.expression; - case 198 /* TemplateSpan */: + case 202 /* 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 252 /* JsxExpression */: + case 251 /* JsxSpreadAttribute */: return true; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7266,7 +7538,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; + return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7275,7 +7547,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; + return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7283,7 +7555,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576 /* JavaScriptFile */); + return node && !!(node.flags & 2097152 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** @@ -7293,7 +7565,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 175 /* CallExpression */ && + var isRequire = expression.kind === 179 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7309,9 +7581,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 === 223 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; } return false; } @@ -7322,11 +7594,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 188 /* BinaryExpression */) { + if (expression.kind !== 192 /* 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 !== 177 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7344,7 +7616,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 === 177 /* 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 */) { @@ -7362,35 +7634,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 235 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 234 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 241 /* ExternalModuleReference */) { + if (reference.kind === 245 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 237 /* ExportDeclaration */) { + if (node.kind === 241 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 234 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 /* ImportDeclaration */ + return node.kind === 235 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7398,13 +7670,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 258 /* ShorthandPropertyAssignment */: + case 257 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7412,9 +7684,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 /* JSDocFunctionType */ && + return node.kind === 274 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 271 /* JSDocConstructorType */; + node.parameters[0].type.kind === 276 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -7474,34 +7746,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 === 205 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201 /* VariableStatement */; + node.parent.parent.kind === 205 /* 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 === 230 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 230 /* 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 === 192 /* BinaryExpression */ && parent_4.operatorToken.kind === 57 /* EqualsToken */ && - parent_4.parent.kind === 203 /* ExpressionStatement */; + parent_4.parent.kind === 207 /* 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 === 257 /* 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)); @@ -7527,14 +7799,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 === 280 /* 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 === 280 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { return paramTags; } @@ -7546,15 +7818,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 282 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); + return getJSDocTag(node, 281 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 283 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -7568,7 +7840,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 === 280 /* JSDocParameterTag */) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -7588,13 +7860,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 === 275 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 275 /* JSDocVariadicType */; } } return isDeclaredRestParam(node); @@ -7604,29 +7876,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 192 /* BinaryExpression */: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + 0 /* None */; + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: + var unaryOperator = parent.operator; + return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; + case 183 /* ParenthesizedExpression */: + case 175 /* ArrayLiteralExpression */: + case 196 /* SpreadElement */: + node = parent; + break; + case 258 /* ShorthandPropertyAssignment */: + if (parent.name !== node) { + return 0 /* None */; + } + // Fall through + case 257 /* 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) { @@ -7640,7 +7936,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 === 261 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7654,7 +7950,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { + if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7667,7 +7963,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; @@ -7675,31 +7971,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 260 /* EnumMember */: + case 257 /* PropertyAssignment */: + case 177 /* 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 174 /* BindingElement */: + case 239 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7715,13 +8011,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 === 234 /* ImportEqualsDeclaration */ || + node.kind === 233 /* NamespaceExportDeclaration */ || + node.kind === 236 /* ImportClause */ && !!node.name || + node.kind === 237 /* NamespaceImport */ || + node.kind === 239 /* ImportSpecifier */ || + node.kind === 243 /* ExportSpecifier */ || + node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7807,7 +8103,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) { @@ -7834,7 +8130,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); } @@ -7849,10 +8145,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; @@ -7891,7 +8187,7 @@ var ts; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: case 114 /* StaticKeyword */: return true; } @@ -7900,11 +8196,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 === 174 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7912,15 +8208,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 === 184 /* FunctionExpression */ + || kind === 225 /* FunctionDeclaration */ + || kind === 185 /* ArrowFunction */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 230 /* ModuleDeclaration */ + || kind === 261 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -7928,13 +8224,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; /** @@ -7974,30 +8270,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 === 180 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176 /* NewExpression */: + case 180 /* 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 190 /* PrefixUnaryExpression */: + case 187 /* TypeOfExpression */: + case 188 /* VoidExpression */: + case 186 /* DeleteExpression */: + case 189 /* AwaitExpression */: + case 193 /* ConditionalExpression */: + case 195 /* YieldExpression */: return 1 /* Right */; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8021,15 +8317,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 === 180 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188 /* BinaryExpression */) { + if (expression.kind === 192 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { + else if (expression.kind === 190 /* PrefixUnaryExpression */ || expression.kind === 191 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8047,36 +8343,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 175 /* ArrayLiteralExpression */: + case 176 /* ObjectLiteralExpression */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 197 /* ClassExpression */: + case 246 /* JsxElement */: + case 247 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 190 /* TemplateExpression */: - case 179 /* ParenthesizedExpression */: - case 194 /* OmittedExpression */: + case 194 /* TemplateExpression */: + case 183 /* ParenthesizedExpression */: + case 198 /* OmittedExpression */: return 19; - case 177 /* TaggedTemplateExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 181 /* TaggedTemplateExpression */: + case 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: return 18; - case 176 /* NewExpression */: + case 180 /* NewExpression */: return hasArguments ? 18 : 17; - case 175 /* CallExpression */: + case 179 /* CallExpression */: return 17; - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return 16; - case 186 /* PrefixUnaryExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 185 /* AwaitExpression */: + case 190 /* PrefixUnaryExpression */: + case 187 /* TypeOfExpression */: + case 188 /* VoidExpression */: + case 186 /* DeleteExpression */: + case 189 /* AwaitExpression */: return 15; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8134,11 +8430,11 @@ var ts; default: return -1; } - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return 4; - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return 2; - case 192 /* SpreadElementExpression */: + case 196 /* SpreadElement */: return 1; default: return -1; @@ -8408,21 +8704,36 @@ 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]; - return ts.filter(sourceFiles, isNonDeclarationFile); + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; + return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); + } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ + function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { + return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + } + ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; function isNonDeclarationFile(sourceFile) { return !isDeclarationFile(sourceFile); } + /** + * Whether a file should be emitted in a non-`--outFile` case. + * Don't emit if source file is a declaration file, or was located under node_modules + */ + function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { + return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); } /** * Iterates over each source file to emit. The source files are expected to have been @@ -8500,11 +8811,10 @@ 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 - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { onSingleFileEmit(host, sourceFile); } } @@ -8537,7 +8847,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)); }); @@ -8577,7 +8887,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; } }); @@ -8619,10 +8929,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 { @@ -8631,7 +8941,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); @@ -8642,10 +8952,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; } } @@ -8872,7 +9182,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } node.modifierFlagsCache = flags | 536870912 /* HasComputedFlags */; @@ -8891,7 +9201,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 */; } @@ -8908,19 +9218,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 === 199 /* 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 === 176 /* ObjectLiteralExpression */ + || kind === 175 /* ArrayLiteralExpression */; } } return false; @@ -8949,20 +9265,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 177 /* 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 === 177 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172 /* ObjectLiteralExpression */) { + if (kind === 176 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 171 /* ArrayLiteralExpression */) { + if (kind === 175 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9124,39 +9440,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 173 /* PropertyAccessExpression */) { + else if (kind === 177 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174 /* ElementAccessExpression */) { + else if (kind === 178 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 /* PrefixUnaryExpression */ - || kind === 187 /* PostfixUnaryExpression */) { + else if (kind === 190 /* PrefixUnaryExpression */ + || kind === 191 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188 /* BinaryExpression */) { + else if (kind === 192 /* 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 === 193 /* 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 === 188 /* VoidExpression */ + || kind === 187 /* TypeOfExpression */ + || kind === 186 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171 /* ArrayLiteralExpression */) { + else if (kind === 175 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 172 /* ObjectLiteralExpression */) { + else if (kind === 176 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 175 /* CallExpression */) { + else if (kind === 179 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9315,28 +9631,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 235 /* 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 234 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -9352,22 +9671,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 240 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; + case 205 /* 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 225 /* 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 226 /* 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 229 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -9382,7 +9790,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 === 226 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9459,16 +9867,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; @@ -9477,7 +9885,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) { @@ -9489,60 +9897,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 168 /* ObjectBindingPattern */ - || kind === 169 /* ArrayBindingPattern */; + || kind === 172 /* ObjectBindingPattern */ + || kind === 173 /* 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 === 203 /* 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 === 257 /* PropertyAssignment */ + || kind === 258 /* ShorthandPropertyAssignment */ + || kind === 259 /* SpreadAssignment */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 244 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + return (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* 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 === 199 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9557,95 +9966,103 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 /* ArrayBindingPattern */ - || kind === 168 /* ObjectBindingPattern */; + return kind === 173 /* ArrayBindingPattern */ + || kind === 172 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170 /* BindingElement */; + return node.kind === 174 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 /* BindingElement */ - || kind === 194 /* OmittedExpression */; + return kind === 174 /* BindingElement */ + || kind === 198 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression + function isArrayLiteralExpression(node) { + return node.kind === 175 /* ArrayLiteralExpression */; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 176 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173 /* PropertyAccessExpression */; + return node.kind === 177 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174 /* ElementAccessExpression */; + return node.kind === 178 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188 /* BinaryExpression */; + return node.kind === 192 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189 /* ConditionalExpression */; + return node.kind === 193 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175 /* CallExpression */; + return node.kind === 179 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 /* TemplateExpression */ + return kind === 194 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192 /* SpreadElementExpression */; + function isSpreadExpression(node) { + return node.kind === 196 /* SpreadElement */; } - ts.isSpreadElementExpression = isSpreadElementExpression; + ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 195 /* ExpressionWithTypeArguments */; + return node.kind === 199 /* 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 === 177 /* PropertyAccessExpression */ + || kind === 178 /* ElementAccessExpression */ + || kind === 180 /* NewExpression */ + || kind === 179 /* CallExpression */ + || kind === 246 /* JsxElement */ + || kind === 247 /* JsxSelfClosingElement */ + || kind === 181 /* TaggedTemplateExpression */ + || kind === 175 /* ArrayLiteralExpression */ + || kind === 183 /* ParenthesizedExpression */ + || kind === 176 /* ObjectLiteralExpression */ + || kind === 197 /* ClassExpression */ + || kind === 184 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 190 /* TemplateExpression */ + || kind === 194 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 197 /* NonNullExpression */; + || kind === 201 /* 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 === 190 /* PrefixUnaryExpression */ + || kind === 191 /* PostfixUnaryExpression */ + || kind === 186 /* DeleteExpression */ + || kind === 187 /* TypeOfExpression */ + || kind === 188 /* VoidExpression */ + || kind === 189 /* AwaitExpression */ + || kind === 182 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9653,13 +10070,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 === 193 /* ConditionalExpression */ + || kind === 195 /* YieldExpression */ + || kind === 185 /* ArrowFunction */ + || kind === 192 /* BinaryExpression */ + || kind === 196 /* SpreadElement */ + || kind === 200 /* AsExpression */ + || kind === 198 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9668,16 +10085,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 /* TypeAssertionExpression */ - || kind === 196 /* AsExpression */; + return kind === 182 /* TypeAssertionExpression */ + || kind === 200 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288 /* PartiallyEmittedExpression */; + return node.kind === 293 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287 /* NotEmittedStatement */; + return node.kind === 292 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9686,17 +10103,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194 /* OmittedExpression */; + return node.kind === 198 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 198 /* TemplateSpan */; + return node.kind === 202 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 200 /* Block */; + return node.kind === 204 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9714,119 +10131,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219 /* VariableDeclaration */; + return node.kind === 223 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220 /* VariableDeclarationList */; + return node.kind === 224 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228 /* CaseBlock */; + return node.kind === 232 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 /* ModuleBlock */ - || kind === 226 /* ModuleDeclaration */; + return kind === 231 /* ModuleBlock */ + || kind === 230 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */; + return node.kind === 234 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232 /* ImportClause */; + return node.kind === 236 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 /* NamedImports */ - || kind === 233 /* NamespaceImport */; + return kind === 238 /* NamedImports */ + || kind === 237 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235 /* ImportSpecifier */; + return node.kind === 239 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238 /* NamedExports */; + return node.kind === 242 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239 /* ExportSpecifier */; + return node.kind === 243 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; + return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* 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 === 185 /* ArrowFunction */ + || kind === 174 /* BindingElement */ + || kind === 226 /* ClassDeclaration */ + || kind === 197 /* ClassExpression */ + || kind === 150 /* Constructor */ + || kind === 229 /* EnumDeclaration */ + || kind === 260 /* EnumMember */ + || kind === 243 /* ExportSpecifier */ + || kind === 225 /* FunctionDeclaration */ + || kind === 184 /* FunctionExpression */ + || kind === 151 /* GetAccessor */ + || kind === 236 /* ImportClause */ + || kind === 234 /* ImportEqualsDeclaration */ + || kind === 239 /* ImportSpecifier */ + || kind === 227 /* InterfaceDeclaration */ + || kind === 149 /* MethodDeclaration */ + || kind === 148 /* MethodSignature */ + || kind === 230 /* ModuleDeclaration */ + || kind === 233 /* NamespaceExportDeclaration */ + || kind === 237 /* NamespaceImport */ + || kind === 144 /* Parameter */ + || kind === 257 /* PropertyAssignment */ + || kind === 147 /* PropertyDeclaration */ + || kind === 146 /* PropertySignature */ + || kind === 152 /* SetAccessor */ + || kind === 258 /* ShorthandPropertyAssignment */ + || kind === 228 /* TypeAliasDeclaration */ + || kind === 143 /* TypeParameter */ + || kind === 223 /* VariableDeclaration */ + || kind === 284 /* 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 === 225 /* FunctionDeclaration */ + || kind === 244 /* MissingDeclaration */ + || kind === 226 /* ClassDeclaration */ + || kind === 227 /* InterfaceDeclaration */ + || kind === 228 /* TypeAliasDeclaration */ + || kind === 229 /* EnumDeclaration */ + || kind === 230 /* ModuleDeclaration */ + || kind === 235 /* ImportDeclaration */ + || kind === 234 /* ImportEqualsDeclaration */ + || kind === 241 /* ExportDeclaration */ + || kind === 240 /* ExportAssignment */ + || kind === 233 /* 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 === 215 /* BreakStatement */ + || kind === 214 /* ContinueStatement */ + || kind === 222 /* DebuggerStatement */ + || kind === 209 /* DoStatement */ + || kind === 207 /* ExpressionStatement */ + || kind === 206 /* EmptyStatement */ + || kind === 212 /* ForInStatement */ + || kind === 213 /* ForOfStatement */ + || kind === 211 /* ForStatement */ + || kind === 208 /* IfStatement */ + || kind === 219 /* LabeledStatement */ + || kind === 216 /* ReturnStatement */ + || kind === 218 /* SwitchStatement */ + || kind === 220 /* ThrowStatement */ + || kind === 221 /* TryStatement */ + || kind === 205 /* VariableStatement */ + || kind === 210 /* WhileStatement */ + || kind === 217 /* WithStatement */ + || kind === 292 /* NotEmittedStatement */ + || kind === 295 /* EndOfDeclarationMarker */ + || kind === 294 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -9847,93 +10266,93 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200 /* Block */; + || kind === 204 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 241 /* ExternalModuleReference */ - || kind === 140 /* QualifiedName */ + return kind === 245 /* ExternalModuleReference */ + || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 244 /* JsxOpeningElement */; + return node.kind === 248 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245 /* JsxClosingElement */; + return node.kind === 249 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 173 /* PropertyAccessExpression */; + || kind === 177 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 /* JsxElement */ - || kind === 248 /* JsxExpression */ - || kind === 243 /* JsxSelfClosingElement */ + return kind === 246 /* JsxElement */ + || kind === 252 /* JsxExpression */ + || kind === 247 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 /* JsxAttribute */ - || kind === 247 /* JsxSpreadAttribute */; + return kind === 250 /* JsxAttribute */ + || kind === 251 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247 /* JsxSpreadAttribute */; + return node.kind === 251 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246 /* JsxAttribute */; + return node.kind === 250 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 248 /* JsxExpression */; + || kind === 252 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 /* CaseClause */ - || kind === 250 /* DefaultClause */; + return kind === 253 /* CaseClause */ + || kind === 254 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251 /* HeritageClause */; + return node.kind === 255 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252 /* CatchClause */; + return node.kind === 256 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 253 /* PropertyAssignment */; + return node.kind === 257 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254 /* ShorthandPropertyAssignment */; + return node.kind === 258 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 260 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 256 /* SourceFile */; + return node.kind === 261 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -9945,6 +10364,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 */: @@ -10162,9 +10582,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 === 227 /* InterfaceDeclaration */) { return current; } } @@ -10172,11 +10592,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 === 174 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10184,14 +10604,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 223 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 224 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 205 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10207,14 +10627,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 223 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 224 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 205 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10229,7 +10649,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 /* SourceFile */ + var ConstructorForKind = kind === 261 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -10412,7 +10832,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; } @@ -10425,17 +10845,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; @@ -10445,17 +10856,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; @@ -10473,7 +10884,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; @@ -10493,7 +10904,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; @@ -10511,7 +10922,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; @@ -10530,7 +10941,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; @@ -10549,7 +10960,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(168 /* ObjectBindingPattern */, location); + var node = createNode(172 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10562,7 +10973,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169 /* ArrayBindingPattern */, location); + var node = createNode(173 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10575,7 +10986,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170 /* BindingElement */, location); + var node = createNode(174 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10592,7 +11003,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171 /* ArrayLiteralExpression */, location); + var node = createNode(175 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10608,7 +11019,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172 /* ObjectLiteralExpression */, location); + var node = createNode(176 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10624,7 +11035,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173 /* PropertyAccessExpression */, location, flags); + var node = createNode(177 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10642,7 +11053,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174 /* ElementAccessExpression */, location); + var node = createNode(178 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10656,7 +11067,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* CallExpression */, location, flags); + var node = createNode(179 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10673,7 +11084,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176 /* NewExpression */, location, flags); + var node = createNode(180 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10688,7 +11099,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177 /* TaggedTemplateExpression */, location); + var node = createNode(181 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10702,7 +11113,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179 /* ParenthesizedExpression */, location); + var node = createNode(183 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10715,7 +11126,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(184 /* FunctionExpression */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10734,7 +11145,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(185 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10752,7 +11163,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182 /* DeleteExpression */, location); + var node = createNode(186 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10765,7 +11176,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183 /* TypeOfExpression */, location); + var node = createNode(187 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10778,7 +11189,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184 /* VoidExpression */, location); + var node = createNode(188 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10791,7 +11202,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185 /* AwaitExpression */, location); + var node = createNode(189 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10804,7 +11215,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186 /* PrefixUnaryExpression */, location); + var node = createNode(190 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10818,7 +11229,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187 /* PostfixUnaryExpression */, location); + var node = createNode(191 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10834,7 +11245,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(192 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10849,7 +11260,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189 /* ConditionalExpression */, location); + var node = createNode(193 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10866,7 +11277,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190 /* TemplateExpression */, location); + var node = createNode(194 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10880,7 +11291,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191 /* YieldExpression */, location); + var node = createNode(195 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10894,7 +11305,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192 /* SpreadElementExpression */, location); + var node = createNode(196 /* SpreadElement */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10907,7 +11318,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193 /* ClassExpression */, location); + var node = createNode(197 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10925,12 +11336,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194 /* OmittedExpression */, location); + var node = createNode(198 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195 /* ExpressionWithTypeArguments */, location); + var node = createNode(199 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10945,7 +11356,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(198 /* TemplateSpan */, location); + var node = createNode(202 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -10960,7 +11371,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(200 /* Block */, location, flags); + var block = createNode(204 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10976,7 +11387,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201 /* VariableStatement */, location, flags); + var node = createNode(205 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10991,7 +11402,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220 /* VariableDeclarationList */, location, flags); + var node = createNode(224 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11004,7 +11415,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219 /* VariableDeclaration */, location, flags); + var node = createNode(223 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11019,11 +11430,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202 /* EmptyStatement */, location); + return createNode(206 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203 /* ExpressionStatement */, location, flags); + var node = createNode(207 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11036,7 +11447,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204 /* IfStatement */, location); + var node = createNode(208 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11051,7 +11462,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205 /* DoStatement */, location); + var node = createNode(209 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11065,7 +11476,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206 /* WhileStatement */, location); + var node = createNode(210 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11079,7 +11490,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11095,7 +11506,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208 /* ForInStatement */, location); + var node = createNode(212 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11110,7 +11521,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209 /* ForOfStatement */, location); + var node = createNode(213 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11125,7 +11536,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210 /* ContinueStatement */, location); + var node = createNode(214 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11140,7 +11551,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211 /* BreakStatement */, location); + var node = createNode(215 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11155,7 +11566,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212 /* ReturnStatement */, location); + var node = createNode(216 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11168,7 +11579,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213 /* WithStatement */, location); + var node = createNode(217 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11182,7 +11593,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214 /* SwitchStatement */, location); + var node = createNode(218 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11196,7 +11607,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215 /* LabeledStatement */, location); + var node = createNode(219 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11210,7 +11621,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216 /* ThrowStatement */, location); + var node = createNode(220 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11223,7 +11634,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217 /* TryStatement */, location); + var node = createNode(221 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11238,7 +11649,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228 /* CaseBlock */, location); + var node = createNode(232 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11251,7 +11662,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(225 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11271,7 +11682,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222 /* ClassDeclaration */, location); + var node = createNode(226 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11289,7 +11700,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231 /* ImportDeclaration */, location); + var node = createNode(235 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11305,7 +11716,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232 /* ImportClause */, location); + var node = createNode(236 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11319,7 +11730,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233 /* NamespaceImport */, location); + var node = createNode(237 /* NamespaceImport */, location); node.name = name; return node; } @@ -11332,7 +11743,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234 /* NamedImports */, location); + var node = createNode(238 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11345,7 +11756,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235 /* ImportSpecifier */, location); + var node = createNode(239 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11359,7 +11770,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236 /* ExportAssignment */, location); + var node = createNode(240 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11375,7 +11786,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237 /* ExportDeclaration */, location); + var node = createNode(241 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11391,7 +11802,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238 /* NamedExports */, location); + var node = createNode(242 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11404,7 +11815,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239 /* ExportSpecifier */, location); + var node = createNode(243 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11419,7 +11830,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242 /* JsxElement */, location); + var node = createNode(246 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11434,7 +11845,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243 /* JsxSelfClosingElement */, location); + var node = createNode(247 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11448,7 +11859,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244 /* JsxOpeningElement */, location); + var node = createNode(248 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11462,7 +11873,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245 /* JsxClosingElement */, location); + var node = createNode(249 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11475,7 +11886,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246 /* JsxAttribute */, location); + var node = createNode(250 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11489,7 +11900,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247 /* JsxSpreadAttribute */, location); + var node = createNode(251 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11502,7 +11913,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248 /* JsxExpression */, location); + var node = createNode(252 /* JsxExpression */, location); node.expression = expression; return node; } @@ -11516,7 +11927,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(251 /* HeritageClause */, location); + var node = createNode(255 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11530,7 +11941,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249 /* CaseClause */, location); + var node = createNode(253 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11544,7 +11955,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250 /* DefaultClause */, location); + var node = createNode(254 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11557,7 +11968,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252 /* CatchClause */, location); + var node = createNode(256 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11572,7 +11983,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(253 /* PropertyAssignment */, location); + var node = createNode(257 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11587,12 +11998,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254 /* ShorthandPropertyAssignment */, location); + var node = createNode(258 /* 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(259 /* 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); @@ -11600,10 +12017,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(261 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11672,11 +12096,33 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(287 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(292 /* 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(295 /* 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(294 /* 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. @@ -11686,7 +12132,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(293 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -11759,15 +12205,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, [ @@ -11807,10 +12244,25 @@ var ts; // flag and setting a parent node. var react = createIdentifier(reactNamespace || "React"); react.flags &= ~8 /* Synthesized */; - react.parent = parent; + // Set the parent that is in parse tree + // this makes sure that parent chain is intact for checker to traverse complete scope tree + 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); @@ -11830,10 +12282,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 */); } @@ -11922,20 +12386,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) { @@ -11960,7 +12422,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"), @@ -11970,9 +12432,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 ])))))); @@ -11988,8 +12449,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, @@ -12019,13 +12480,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12045,7 +12506,7 @@ var ts; } else { switch (callee.kind) { - case 173 /* PropertyAccessExpression */: { + case 177 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12059,7 +12520,7 @@ var ts; } break; } - case 174 /* ElementAccessExpression */: { + case 178 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12113,14 +12574,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 257 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12184,6 +12645,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"; @@ -12273,7 +12840,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 === 183 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12307,8 +12874,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(192 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(192 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12317,7 +12884,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 === 195 /* YieldExpression */) { return false; } return true; @@ -12405,7 +12972,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12428,9 +12995,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175 /* CallExpression */: + case 179 /* CallExpression */: return createParen(expression); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12455,7 +13022,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 180 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12493,7 +13060,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(192 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12504,7 +13071,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 === 184 /* FunctionExpression */ || kind === 185 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12512,7 +13079,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { + if (leftmostExpressionKind === 176 /* ObjectLiteralExpression */ || leftmostExpressionKind === 184 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12536,21 +13103,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: node = node.operand; continue; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: node = node.left; continue; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: node = node.condition; continue; - case 175 /* CallExpression */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 179 /* CallExpression */: + case 178 /* ElementAccessExpression */: + case 177 /* PropertyAccessExpression */: node = node.expression; continue; - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -12559,19 +13126,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 176 /* 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; @@ -12591,7 +13158,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */) { + while (node.kind === 183 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12605,7 +13172,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288 /* PartiallyEmittedExpression */) { + while (node.kind === 293 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -12680,7 +13247,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 === 261 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12822,13 +13389,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 === 235 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12885,6 +13452,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 === 185 /* 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 !== 185 /* 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 = {})); /// /// @@ -12896,13 +13820,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256 /* SourceFile */) { + if (kind === 261 /* 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 { @@ -12945,26 +13869,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 258 /* 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 259 /* SpreadAssignment */: + return visitNode(cbNode, node.expression); + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 257 /* PropertyAssignment */: + case 223 /* VariableDeclaration */: + case 174 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12973,24 +13899,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13001,308 +13927,318 @@ 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 /* MappedType */: + return visitNode(cbNode, node.readonlyToken) || + visitNode(cbNode, node.typeParameter) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type); + case 171 /* LiteralType */: return visitNode(cbNode, node.literal); - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178 /* TypeAssertionExpression */: + case 182 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196 /* AsExpression */: + case 200 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 189 /* ConditionalExpression */: + case 193 /* 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 196 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 204 /* Block */: + case 231 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 256 /* SourceFile */: + case 261 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 214 /* ContinueStatement */: + case 215 /* BreakStatement */: return visitNode(cbNode, node.label); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 249 /* CaseClause */: + case 253 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252 /* CatchClause */: + case 256 /* 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 226 /* ClassDeclaration */: + case 197 /* 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 227 /* 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 228 /* 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 229 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255 /* EnumMember */: + case 260 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229 /* NamespaceExportDeclaration */: + case 233 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 237 /* ExportDeclaration */: + case 241 /* 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 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198 /* TemplateSpan */: + case 202 /* 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 255 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241 /* ExternalModuleReference */: + case 245 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 240 /* MissingDeclaration */: + case 244 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 242 /* JsxElement */: + case 246 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 247 /* JsxSelfClosingElement */: + case 248 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 257 /* JSDocTypeExpression */: + case 262 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 261 /* JSDocUnionType */: + case 266 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 262 /* JSDocTupleType */: + case 267 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 260 /* JSDocArrayType */: + case 265 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 264 /* JSDocNonNullableType */: + case 269 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 263 /* JSDocNullableType */: + case 268 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 265 /* JSDocRecordType */: + case 270 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 267 /* JSDocTypeReference */: + case 272 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 268 /* JSDocOptionalType */: + case 273 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 269 /* JSDocFunctionType */: + case 274 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 270 /* JSDocVariadicType */: + case 275 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 271 /* JSDocConstructorType */: + case 276 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 272 /* JSDocThisType */: + case 277 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 266 /* JSDocRecordMember */: + case 271 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273 /* JSDocComment */: + case 278 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 275 /* JSDocParameterTag */: + case 280 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276 /* JSDocReturnTag */: + case 281 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 277 /* JSDocTypeTag */: + case 282 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 278 /* JSDocTemplateTag */: + case 283 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281 /* JSDocTypeLiteral */: + case 286 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280 /* JSDocPropertyTag */: + case 285 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 282 /* JSDocLiteralType */: + case 287 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -13316,6 +14252,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; } @@ -13357,8 +14297,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; @@ -13456,6 +14396,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 */; @@ -13472,7 +14422,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); @@ -13560,7 +14510,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(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13580,16 +14530,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 @@ -13630,40 +14580,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(); @@ -13844,7 +14794,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); } @@ -13867,7 +14817,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; } @@ -13936,7 +14886,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 @@ -14023,9 +14973,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. @@ -14045,29 +14997,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'."); @@ -14120,7 +15072,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 */; @@ -14128,35 +15080,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 */; } } @@ -14183,7 +15136,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; @@ -14258,7 +15211,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; } @@ -14293,20 +15246,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 @@ -14314,7 +15269,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. @@ -14338,14 +15293,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 203 /* 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. @@ -14360,8 +15315,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 253 /* CaseClause */: + case 254 /* DefaultClause */: return true; } } @@ -14370,58 +15325,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 225 /* FunctionDeclaration */: + case 205 /* VariableStatement */: + case 204 /* Block */: + case 208 /* IfStatement */: + case 207 /* ExpressionStatement */: + case 220 /* ThrowStatement */: + case 216 /* ReturnStatement */: + case 218 /* SwitchStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 211 /* ForStatement */: + case 210 /* WhileStatement */: + case 217 /* WithStatement */: + case 206 /* EmptyStatement */: + case 221 /* TryStatement */: + case 219 /* LabeledStatement */: + case 209 /* DoStatement */: + case 222 /* DebuggerStatement */: + case 235 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 241 /* ExportDeclaration */: + case 240 /* ExportAssignment */: + case 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 228 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 260 /* 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 !== 223 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14442,7 +15397,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. @@ -14464,6 +15419,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; @@ -14475,17 +15431,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; } } ; @@ -14554,7 +15510,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); @@ -14593,7 +15549,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190 /* TemplateExpression */); + var template = createNode(194 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14605,7 +15561,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198 /* TemplateSpan */); + var span = createNode(202 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -14660,33 +15616,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 @@ -14711,7 +15667,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() { @@ -14724,7 +15680,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(); @@ -14823,7 +15779,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); @@ -14887,7 +15843,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 */); @@ -14899,7 +15855,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; @@ -14910,7 +15866,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; @@ -14959,10 +15915,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(); @@ -14976,7 +15932,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); } @@ -14991,13 +15947,40 @@ var ts; } return members; } + function isStartOfMappedType() { + nextToken(); + if (token() === 130 /* ReadonlyKeyword */) { + nextToken(); + } + return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; + } + function parseMappedTypeParameter() { + var node = createNode(143 /* TypeParameter */); + node.name = parseIdentifier(); + parseExpected(91 /* InKeyword */); + node.constraint = parseType(); + return finishNode(node); + } + function parseMappedType() { + var node = createNode(170 /* MappedType */); + parseExpected(16 /* OpenBraceToken */); + node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); + parseExpected(20 /* OpenBracketToken */); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(21 /* CloseBracketToken */); + node.questionToken = parseOptionalToken(54 /* QuestionToken */); + node.type = parseTypeAnnotation(); + parseSemicolon(); + parseExpected(17 /* CloseBraceToken */); + return finishNode(node); + } 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 */); @@ -15005,7 +15988,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); @@ -15016,7 +15999,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167 /* LiteralType */); + var node = createNode(171 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15027,12 +16010,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(); @@ -15058,7 +16041,7 @@ var ts; case 102 /* TypeOfKeyword */: return parseTypeQuery(); case 16 /* OpenBraceToken */: - return parseTypeLiteral(); + return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); case 20 /* OpenBracketToken */: return parseTupleType(); case 18 /* OpenParenToken */: @@ -15070,16 +16053,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 */: @@ -15106,13 +16089,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) { @@ -15128,10 +16134,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 */) { @@ -15188,7 +16194,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); @@ -15207,14 +16213,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(); } @@ -15415,7 +16421,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191 /* YieldExpression */); + var node = createNode(195 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -15437,13 +16443,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(185 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181 /* ArrowFunction */, identifier.pos); + node = createNode(185 /* 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); @@ -15625,7 +16631,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181 /* ArrowFunction */); + var node = createNode(185 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15691,7 +16697,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(193 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15704,7 +16710,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) { @@ -15812,39 +16818,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188 /* BinaryExpression */, left.pos); + var node = createNode(192 /* 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(200 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(190 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182 /* DeleteExpression */); + var node = createNode(186 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183 /* TypeOfExpression */); + var node = createNode(187 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184 /* VoidExpression */); + var node = createNode(188 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15860,7 +16866,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185 /* AwaitExpression */); + var node = createNode(189 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15903,7 +16909,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 === 182 /* 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 { @@ -15999,7 +17005,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(190 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -16012,7 +17018,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(191 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16116,7 +17122,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(177 /* 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); @@ -16141,8 +17147,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 === 248 /* JsxOpeningElement */) { + var node = createNode(246 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16152,7 +17158,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16167,7 +17173,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(192 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16226,7 +17232,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(248 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -16238,7 +17244,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(243 /* JsxSelfClosingElement */, fullStart); + node = createNode(247 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16254,7 +17260,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16262,7 +17268,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248 /* JsxExpression */); + var node = createNode(252 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -16281,7 +17287,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246 /* JsxAttribute */); + var node = createNode(250 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -16296,7 +17302,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247 /* JsxSpreadAttribute */); + var node = createNode(251 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -16304,7 +17310,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245 /* JsxClosingElement */); + var node = createNode(249 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16317,7 +17323,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178 /* TypeAssertionExpression */); + var node = createNode(182 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -16328,7 +17334,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16336,14 +17342,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(201 /* 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(178 /* 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. @@ -16359,7 +17365,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(181 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -16382,7 +17388,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(179 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16390,7 +17396,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(179 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16409,7 +17415,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; @@ -16500,28 +17506,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179 /* ParenthesizedExpression */); + var node = createNode(183 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192 /* SpreadElementExpression */); + var node = createNode(196 /* 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(198 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171 /* ArrayLiteralExpression */); + var node = createNode(175 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16532,15 +17538,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(259 /* SpreadAssignment */, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -16562,7 +17574,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(258 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -16573,7 +17585,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16583,7 +17595,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172 /* ObjectLiteralExpression */); + var node = createNode(176 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16602,7 +17614,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(180 /* FunctionExpression */); + var node = createNode(184 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -16624,7 +17636,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176 /* NewExpression */); + var node = createNode(180 /* NewExpression */); parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -16635,7 +17647,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200 /* Block */); + var node = createNode(204 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16668,12 +17680,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202 /* EmptyStatement */); + var node = createNode(206 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(204 /* IfStatement */); + var node = createNode(208 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16683,7 +17695,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205 /* DoStatement */); + var node = createNode(209 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -16698,7 +17710,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206 /* WhileStatement */); + var node = createNode(210 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16721,21 +17733,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(208 /* ForInStatement */, pos); + var forInStatement = createNode(212 /* 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(213 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207 /* ForStatement */, pos); + var forStatement = createNode(211 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -16753,7 +17765,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16761,7 +17773,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212 /* ReturnStatement */); + var node = createNode(216 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16770,7 +17782,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213 /* WithStatement */); + var node = createNode(217 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16779,7 +17791,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249 /* CaseClause */); + var node = createNode(253 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -16787,7 +17799,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250 /* DefaultClause */); + var node = createNode(254 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -16797,12 +17809,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214 /* SwitchStatement */); + var node = createNode(218 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -16817,7 +17829,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(220 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -16825,7 +17837,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(217 /* TryStatement */); + var node = createNode(221 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -16838,7 +17850,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252 /* CatchClause */); + var result = createNode(256 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16848,7 +17860,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218 /* DebuggerStatement */); + var node = createNode(222 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -16860,13 +17872,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(219 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16916,10 +17928,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 */: @@ -16927,14 +17939,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 */: @@ -16994,17 +18006,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); @@ -17047,9 +18059,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(210 /* ContinueStatement */); + return parseBreakOrContinueStatement(214 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(211 /* BreakStatement */); + return parseBreakOrContinueStatement(215 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -17069,9 +18081,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 */: @@ -17082,8 +18094,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(); } @@ -17106,13 +18118,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); @@ -17131,7 +18143,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(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17153,16 +18165,17 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(194 /* OmittedExpression */); + return createNode(198 /* OmittedExpression */); } - var node = createNode(170 /* BindingElement */); + var node = createNode(174 /* 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(174 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { @@ -17177,14 +18190,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168 /* ObjectBindingPattern */); + var node = createNode(172 /* 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(173 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -17203,7 +18216,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219 /* VariableDeclaration */); + var node = createNode(223 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17212,7 +18225,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220 /* VariableDeclarationList */); + var node = createNode(224 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -17235,7 +18248,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 { @@ -17250,7 +18263,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201 /* VariableStatement */, fullStart); + var node = createNode(205 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17258,7 +18271,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221 /* FunctionDeclaration */, fullStart); + var node = createNode(225 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -17271,7 +18284,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 */); @@ -17280,7 +18293,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; @@ -17293,7 +18306,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; @@ -17310,7 +18323,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)); } @@ -17345,7 +18358,7 @@ var ts; case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: return true; default: return false; @@ -17386,7 +18399,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 @@ -17416,7 +18429,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) { @@ -17482,7 +18495,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(199 /* SemicolonClassElement */); + var result = createNode(203 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17510,8 +18523,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."); @@ -17520,10 +18533,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 193 /* ClassExpression */); + /*modifiers*/ undefined, 197 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17561,13 +18574,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(255 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -17576,10 +18589,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195 /* ExpressionWithTypeArguments */); + var node = createNode(199 /* 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); } @@ -17590,7 +18603,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* InterfaceDeclaration */, fullStart); + var node = createNode(227 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -17601,10 +18614,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* TypeAliasDeclaration */, fullStart); + var node = createNode(228 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135 /* TypeKeyword */); + parseExpected(136 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -17617,13 +18630,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(260 /* 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(229 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -17638,7 +18651,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -17649,7 +18662,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(230 /* 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 */; @@ -17663,10 +18676,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(230 /* 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 */; @@ -17684,15 +18697,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); } @@ -17700,7 +18713,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 /* RequireKeyword */ && + return token() === 131 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -17710,13 +18723,13 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); - parseExpected(127 /* NamespaceKeyword */); + parseExpected(128 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); - parseExpected(24 /* SemicolonToken */); + parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { @@ -17725,11 +18738,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(234 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17740,7 +18753,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -17750,7 +18763,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137 /* FromKeyword */); + parseExpected(138 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17763,7 +18776,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(232 /* ImportClause */, fullStart); + var importClause = createNode(236 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17773,7 +18786,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(238 /* NamedImports */); } return finishNode(importClause); } @@ -17783,8 +18796,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(241 /* ExternalModuleReference */); - parseExpected(130 /* RequireKeyword */); + var node = createNode(245 /* ExternalModuleReference */); + parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(19 /* CloseParenToken */); @@ -17806,7 +18819,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(233 /* NamespaceImport */); + var namespaceImport = createNode(237 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -17821,14 +18834,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 === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239 /* ExportSpecifier */); + return parseImportOrExportSpecifier(243 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235 /* ImportSpecifier */); + return parseImportOrExportSpecifier(239 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17853,27 +18866,27 @@ var ts; else { node.name = identifierName; } - if (kind === 235 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 239 /* 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(241 /* 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(242 /* 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(); } } @@ -17881,7 +18894,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236 /* ExportAssignment */, fullStart); + var node = createNode(240 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -17963,10 +18976,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 === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ + || node.kind === 235 /* ImportDeclaration */ + || node.kind === 240 /* ExportAssignment */ + || node.kind === 241 /* ExportDeclaration */ ? node : undefined; }); @@ -17990,16 +19003,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) { @@ -18027,8 +19041,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(); @@ -18040,7 +19054,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -18051,12 +19065,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(261 /* JSDocUnionType */, type.pos); + var unionType = createNode(266 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -18067,20 +19081,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(260 /* JSDocArrayType */, type.pos); + var arrayType = createNode(265 /* 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(268 /* 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(269 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -18114,14 +19128,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 */: @@ -18132,30 +19146,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272 /* JSDocThisType */); + var result = createNode(277 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271 /* JSDocConstructorType */); + var result = createNode(276 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270 /* JSDocVariadicType */); + var result = createNode(275 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269 /* JSDocFunctionType */); + var result = createNode(274 /* 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 */) { @@ -18165,7 +19179,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? @@ -18174,7 +19188,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267 /* JSDocTypeReference */); + var result = createNode(272 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -18195,7 +19209,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 */); @@ -18209,26 +19223,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(270 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264 /* JSDocNonNullableType */); + var result = createNode(269 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262 /* JSDocTupleType */); + var result = createNode(267 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21 /* CloseBracketToken */); return finishNode(result); @@ -18240,7 +19254,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261 /* JSDocUnionType */); + var result = createNode(266 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -18256,12 +19270,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258 /* JSDocAllType */); + var result = createNode(263 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282 /* JSDocLiteralType */); + var result = createNode(287 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -18284,17 +19298,17 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(259 /* JSDocUnknownType */, pos); + var result = createNode(264 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(263 /* JSDocNullableType */, pos); + var result = createNode(268 /* 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; @@ -18359,6 +19373,7 @@ var ts; } if (token() === 4 /* NewLineTrivia */) { state = 0 /* BeginningOfLine */; + indent = 0; nextJSDocToken(); } while (token() !== 1 /* EndOfFileToken */) { @@ -18447,7 +19462,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(273 /* JSDocComment */, start); + var result = createNode(278 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18560,7 +19575,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274 /* JSDocTag */, atToken.pos); + var result = createNode(279 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -18617,7 +19632,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275 /* JSDocParameterTag */, atToken.pos); + var result = createNode(280 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -18628,20 +19643,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 === 281 /* 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(281 /* 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 === 282 /* 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(282 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18656,7 +19671,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(285 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18666,18 +19681,25 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(284 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; - typedefTag.name = parseJSDocIdentifierName(); + typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); + if (typedefTag.fullName) { + var rightNode = typedefTag.fullName; + while (rightNode.kind !== 70 /* Identifier */) { + rightNode = rightNode.body; + } + typedefTag.name = rightNode; + } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 272 /* 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(); } } @@ -18691,7 +19713,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18728,6 +19750,21 @@ var ts; scanner.setTextPos(resumePos); return finishNode(jsDocTypeLiteral); } + function parseJSDocTypeNameWithNamespace(flags) { + var pos = scanner.getTokenPos(); + var typeNameOrNamespaceName = parseJSDocIdentifierName(); + if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { + var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + jsDocNamespaceNode.flags |= flags; + jsDocNamespaceNode.name = typeNameOrNamespaceName; + jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); + return jsDocNamespaceNode; + } + if (typeNameOrNamespaceName && flags & 4 /* NestedNamespace */) { + typeNameOrNamespaceName.isInJSDocNamespace = true; + } + return typeNameOrNamespaceName; + } } function tryParseChildTag(parentTag) { ts.Debug.assert(token() === 56 /* AtToken */); @@ -18749,30 +19786,34 @@ var ts; return true; case "prop": case "property": - if (!parentTag.jsDocPropertyTags) { - parentTag.jsDocPropertyTags = []; - } var propertyTag = parsePropertyTag(atToken, tagName); - parentTag.jsDocPropertyTags.push(propertyTag); - return true; + if (propertyTag) { + if (!parentTag.jsDocPropertyTags) { + parentTag.jsDocPropertyTags = []; + } + parentTag.jsDocPropertyTags.push(propertyTag); + return true; + } + // Error parsing property tag + return false; } 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 === 283 /* 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 */) { @@ -18783,7 +19824,7 @@ var ts; break; } } - var result = createNode(278 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(283 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -19294,25 +20335,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 === 227 /* InterfaceDeclaration */ || node.kind === 228 /* 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 === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 227 /* ModuleBlock */) { + else if (node.kind === 231 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19331,10 +20372,13 @@ var ts; }); return state_1; } - else if (node.kind === 226 /* ModuleDeclaration */) { + else if (node.kind === 230 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } + else if (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace) { + return 0 /* NonInstantiated */; + } else { return 1 /* Instantiated */; } @@ -19469,7 +20513,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 === 230 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19482,7 +20526,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)) { @@ -19494,21 +20538,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 241 /* ExportDeclaration */: return "__export"; - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19523,22 +20567,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: + case 225 /* FunctionDeclaration */: + case 226 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 269 /* JSDocFunctionType */: + case 274 /* 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 === 274 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 205 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -19625,7 +20669,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 === 240 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19645,7 +20689,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 === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19668,7 +20712,11 @@ 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. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) { + var isJSDocTypedefInJSDocNamespace = node.kind === 284 /* JSDocTypedefTag */ && + node.name && + node.name.kind === 70 /* Identifier */ && + node.name.isInJSDocNamespace; + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793064 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1920 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -19726,8 +20774,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(); @@ -19746,13 +20794,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 === 261 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -19787,6 +20835,7 @@ var ts; skipTransformFlagAggregation = true; bindChildrenWorker(node); skipTransformFlagAggregation = false; + subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); } else { var savedSubtreeTransformFlags = subtreeTransformFlags; @@ -19807,64 +20856,64 @@ var ts; return; } switch (node.kind) { - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: bindWhileStatement(node); break; - case 205 /* DoStatement */: + case 209 /* DoStatement */: bindDoStatement(node); break; - case 207 /* ForStatement */: + case 211 /* ForStatement */: bindForStatement(node); break; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 204 /* IfStatement */: + case 208 /* IfStatement */: bindIfStatement(node); break; - case 212 /* ReturnStatement */: - case 216 /* ThrowStatement */: + case 216 /* ReturnStatement */: + case 220 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 217 /* TryStatement */: + case 221 /* TryStatement */: bindTryStatement(node); break; - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: bindSwitchStatement(node); break; - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: bindCaseBlock(node); break; - case 249 /* CaseClause */: + case 253 /* CaseClause */: bindCaseClause(node); break; - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: bindLabeledStatement(node); break; - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 175 /* CallExpression */: + case 179 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19876,15 +20925,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return hasNarrowableArgument(expr); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -19892,7 +20941,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 177 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19903,14 +20952,14 @@ var ts; } } } - if (expr.expression.kind === 173 /* PropertyAccessExpression */ && + if (expr.expression.kind === 177 /* 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 === 187 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -19931,9 +20980,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -20028,33 +21077,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204 /* IfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 208 /* IfStatement */: + case 210 /* WhileStatement */: + case 209 /* DoStatement */: return parent.expression === node; - case 207 /* ForStatement */: - case 189 /* ConditionalExpression */: + case 211 /* ForStatement */: + case 193 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 183 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 190 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 192 /* 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 === 183 /* ParenthesizedExpression */ || + node.parent.kind === 190 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -20096,8 +21145,13 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 219 /* 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); @@ -20128,7 +21182,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220 /* VariableDeclarationList */) { + if (node.initializer.kind !== 224 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20150,7 +21204,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212 /* ReturnStatement */) { + if (node.kind === 216 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20170,7 +21224,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20210,7 +21264,7 @@ var ts; currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it - // otherwise check if flows after try and after catch are unreachable + // otherwise check if flows after try and after catch are unreachable // if yes - convert current flow to unreachable // i.e. // try { return "1" } finally { console.log(1); } @@ -20236,7 +21290,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 === 254 /* 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; @@ -20299,11 +21353,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 !== 209 /* 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 === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20314,10 +21371,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171 /* ArrayLiteralExpression */) { + else if (node.kind === 175 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192 /* SpreadElementExpression */) { + if (e.kind === 196 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20325,15 +21382,18 @@ var ts; } } } - else if (node.kind === 172 /* ObjectLiteralExpression */) { + else if (node.kind === 176 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253 /* PropertyAssignment */) { + if (p.kind === 257 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254 /* ShorthandPropertyAssignment */) { + else if (p.kind === 258 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 259 /* SpreadAssignment */) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -20385,9 +21445,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 === 178 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20398,7 +21458,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 177 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20408,9 +21468,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); @@ -20429,7 +21491,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 === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20438,10 +21500,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 === 183 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { + if (expr.kind === 184 /* FunctionExpression */ || expr.kind === 185 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20449,7 +21511,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 177 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20458,51 +21520,52 @@ 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 197 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 176 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 286 /* JSDocTypeLiteral */: + case 270 /* JSDocRecordType */: return 1 /* IsContainer */; - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 269 /* JSDocFunctionType */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 274 /* JSDocFunctionType */: + case 230 /* ModuleDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 170 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 256 /* SourceFile */: + case 261 /* 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 225 /* 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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 227 /* ModuleBlock */: + case 231 /* 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 256 /* CatchClause */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 232 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 200 /* Block */: + case 204 /* 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 @@ -20539,41 +21602,42 @@ 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 230 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256 /* SourceFile */: + case 261 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 226 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225 /* EnumDeclaration */: + case 229 /* 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 176 /* ObjectLiteralExpression */: + case 227 /* InterfaceDeclaration */: + case 270 /* JSDocRecordType */: + case 286 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 274 /* JSDocFunctionType */: + case 228 /* TypeAliasDeclaration */: + case 170 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -20594,11 +21658,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 === 261 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* 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 === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { return true; } } @@ -20691,7 +21755,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 === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20703,7 +21767,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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20725,10 +21789,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -20839,8 +21903,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 !== 261 /* SourceFile */ && + blockScopeContainer.kind !== 230 /* 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. @@ -20906,7 +21970,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); @@ -20948,17 +22012,28 @@ var ts; switch (node.kind) { /* Strict mode checks */ case 70 /* Identifier */: + // for typedef type names with namespaces, bind the new jsdoc type symbol here + // because it requires all containing namespaces to be in effect, namely the + // current "blockScopeContainer" needs to be set to its immediate namespace parent. + if (node.isInJSDocNamespace) { + var parentNode = node.parent; + while (parentNode && parentNode.kind !== 284 /* 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 === 258 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20982,119 +22057,140 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return checkStrictModeCatchClause(node); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 213 /* WithStatement */: + case 217 /* 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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + if (node.dotDotDotToken && node.parent.kind === 172 /* ObjectBindingPattern */) { + emitFlags |= 32768 /* HasRestAttribute */; + } return bindVariableDeclarationOrBindingElement(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 266 /* JSDocRecordMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 271 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 280 /* JSDocPropertyTag */: + case 285 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 255 /* EnumMember */: + case 260 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 247 /* JsxSpreadAttribute */: - emitFlags |= 16384 /* HasJsxSpreadAttributes */; + case 259 /* SpreadAssignment */: + case 251 /* JsxSpreadAttribute */: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 176 /* ObjectLiteralExpression */ && + root.parent.kind === 192 /* 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 225 /* 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 274 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 265 /* JSDocRecordType */: + case 161 /* TypeLiteral */: + case 170 /* MappedType */: + case 286 /* JSDocTypeLiteral */: + case 270 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return bindFunctionExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 226 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 279 /* JSDocTypedefTag */: - case 224 /* TypeAliasDeclaration */: + case 284 /* JSDocTypedefTag */: + if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); + } + break; + case 228 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 230 /* ImportEqualsDeclaration */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 237 /* NamespaceImport */: + case 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 229 /* NamespaceExportDeclaration */: + case 233 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return bindImportClause(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return bindExportDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return bindExportAssignment(node); - case 256 /* SourceFile */: + case 261 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200 /* Block */: + case 204 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -21103,7 +22199,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); @@ -21126,7 +22222,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 === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21136,17 +22232,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 !== 261 /* 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; } @@ -21191,12 +22287,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 === 225 /* FunctionDeclaration */ || container.kind === 184 /* 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; @@ -21247,7 +22343,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 226 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21391,13 +22487,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 !== 206 /* EmptyStatement */) || // report error on class declarations - node.kind === 222 /* ClassDeclaration */ || + node.kind === 226 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 /* 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 === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21411,7 +22507,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 !== 205 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21431,54 +22527,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175 /* CallExpression */: + case 179 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 143 /* Parameter */: + case 144 /* Parameter */: return computeParameter(node, subtreeFlags); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 195 /* ExpressionWithTypeArguments */: + case 256 /* CatchClause */: + return computeCatchClause(node, subtreeFlags); + case 199 /* 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 234 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21492,21 +22590,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 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -21518,31 +22616,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 === 176 /* 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 === 175 /* 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; @@ -21554,21 +22655,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; @@ -21578,17 +22683,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 === 200 /* AsExpression */ + || expressionKind === 182 /* 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; @@ -21599,47 +22704,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. @@ -21650,19 +22755,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 |= 3072 /* AssertES2015 */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + 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; @@ -21672,11 +22785,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 @@ -21688,14 +22801,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; @@ -21708,7 +22821,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. @@ -21716,10 +22829,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; @@ -21731,11 +22844,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 */ @@ -21745,13 +22854,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 @@ -21759,11 +22872,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; @@ -21776,13 +22889,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 @@ -21790,14 +22907,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 */) @@ -21807,14 +22924,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; @@ -21823,24 +22944,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 === 172 /* ObjectBindingPattern */) { + transformFlags |= 48 /* AssertESNext */ | 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; + } + else if (nameKind === 173 /* 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; @@ -21852,26 +22977,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; @@ -21880,18 +23001,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 */; @@ -21900,29 +23021,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 189 /* AwaitExpression */: // async/await is ES2017 syntax - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; break; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: @@ -21930,84 +23051,86 @@ 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 229 /* EnumDeclaration */: + case 260 /* EnumMember */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: + case 201 /* NonNullExpression */: + case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 246 /* JsxElement */: + case 247 /* JsxSelfClosingElement */: + case 248 /* JsxOpeningElement */: case 10 /* JsxText */: - case 245 /* JsxClosingElement */: - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: - case 248 /* JsxExpression */: + case 249 /* JsxClosingElement */: + case 250 /* JsxAttribute */: + case 251 /* JsxSpreadAttribute */: + case 252 /* 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 213 /* 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 194 /* TemplateExpression */: + case 181 /* TaggedTemplateExpression */: + case 258 /* ShorthandPropertyAssignment */: + case 114 /* StaticKeyword */: // These nodes are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; - case 191 /* YieldExpression */: + case 195 /* 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 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 167 /* ThisType */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* MappedType */: + case 171 /* 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`), @@ -22016,75 +23139,151 @@ 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 196 /* SpreadElement */: + case 259 /* SpreadAssignment */: + // This node is ES6 or ES next syntax, but is handled by a containing node. + transformFlags |= 8388608 /* ContainsSpreadExpression */; break; + case 174 /* 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 172 /* ObjectBindingPattern */: + case 173 /* 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 176 /* 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 175 /* ArrayLiteralExpression */: + case 180 /* 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 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 211 /* ForStatement */: + case 212 /* 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 261 /* SourceFile */: + if (subtreeFlags & 524288 /* ContainsCapturedLexicalThis */) { + transformFlags |= 3072 /* AssertES2015 */; } break; - case 212 /* ReturnStatement */: - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: - transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; + case 216 /* ReturnStatement */: + case 214 /* ContinueStatement */: + case 215 /* BreakStatement */: + transformFlags |= 268435456 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; return transformFlags & ~excludeFlags; } + /** + * Gets the transform flags to exclude when unioning the transform flags of a subtree. + * + * NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`. + * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather + * than calling this function. + */ + /* @internal */ + function getTransformFlagsSubtreeExclusions(kind) { + if (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) { + return -3 /* TypeExcludes */; + } + switch (kind) { + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 175 /* ArrayLiteralExpression */: + return 545281365 /* ArrayLiteralOrCallOrNewExcludes */; + case 230 /* ModuleDeclaration */: + return 839734613 /* ModuleExcludes */; + case 144 /* Parameter */: + return 604001621 /* ParameterExcludes */; + case 185 /* ArrowFunction */: + return 979719509 /* ArrowFunctionExcludes */; + case 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + return 980243797 /* FunctionExcludes */; + case 224 /* VariableDeclarationList */: + return 604001621 /* VariableDeclarationListExcludes */; + case 226 /* ClassDeclaration */: + case 197 /* 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 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: + case 134 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 135 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 143 /* TypeParameter */: + case 146 /* PropertySignature */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + return -3 /* TypeExcludes */; + case 176 /* ObjectLiteralExpression */: + return 554784085 /* ObjectLiteralExcludes */; + default: + return 536892757 /* NodeExcludes */; + } + } + ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; })(ts || (ts = {})); /// /// @@ -22099,25 +23298,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) { @@ -22126,19 +23363,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 { @@ -22150,7 +23374,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -22162,7 +23385,9 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } } ts.getEffectiveTypeRoots = getEffectiveTypeRoots; /** @@ -22174,17 +23399,12 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_7 = ts.getDirectoryPath(currentDirectory); - if (parent_7 === currentDirectory) { - break; - } - currentDirectory = parent_7; - } + }); return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); @@ -22198,7 +23418,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -22221,64 +23440,59 @@ var ts; } } var failedLookupLocations = []; - // Check primary library paths - if (typeRoots && typeRoots.length) { + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_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) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + // Check primary library paths + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = 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); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + function secondaryLookup() { + var resolvedFile; + 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); } - else { + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; /** @@ -22417,15 +23631,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; } @@ -22463,7 +23677,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; } @@ -22482,7 +23696,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; } @@ -22493,7 +23707,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; } @@ -22509,70 +23723,82 @@ var ts; matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); 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; + // A path mapping may have a ".ts" extension; in contrast to an import, which should omit it. + var tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return path_1 && { path: path_1, extension: tsExtension }; } - } - return undefined; + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); } else { var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); 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, 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); + // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. + return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, 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 realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + 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) { @@ -22584,9 +23810,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; } @@ -22598,11 +23824,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); @@ -22610,12 +23836,21 @@ 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) { + function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); @@ -22626,30 +23861,34 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } - failedLookupLocation.push(fileName); + failedLookupLocations.push(fileName); return undefined; } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); if (directoryExists && state.host.fileExists(packageJsonPath)) { 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, failedLookupLocations, 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 */, failedLookupLocations, 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); } } } @@ -22658,101 +23897,106 @@ var ts; trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } // 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); + failedLookupLocations.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !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) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); + // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. + return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); } - function loadModuleFromNodeModulesWorker(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; - } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; - } - directory = parentPath; + }); + } + /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== 1 /* JavaScript */) { + return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); } - return undefined; } 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)) { + // Climb up parent directories looking for a module. + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, 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) { + /** + * 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 = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ + function forEachAncestorDirectory(directory, callback) { while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - if (referencedSourceFile) { - return referencedSourceFile; + var result = callback(directory); + if (result !== undefined) { + return result; } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { return undefined; } - containingDirectory = parentPath; + directory = parentPath; } } })(ts || (ts = {})); @@ -22854,7 +24098,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(); @@ -22868,9 +24117,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 */ | 33554432 /* 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 */ | 33554432 /* 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"); @@ -22880,13 +24129,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 |= 134217728 /* 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); @@ -23045,6 +24298,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 = { @@ -23074,6 +24329,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. @@ -23157,7 +24427,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 === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23219,7 +24489,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; } @@ -23260,8 +24530,11 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } + function getObjectFlags(type) { + return type.flags & 32768 /* Object */ ? type.objectFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 256 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -23307,24 +24580,30 @@ var ts; // nodes are in different files and order cannot be determines return true; } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + if (isUsedInFunctionOrNonStaticProperty(usage)) { + return true; + } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } 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 !== 223 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - return isUsedInFunctionOrNonStaticProperty(declaration, usage); + var container = ts.getEnclosingBlockScopeContainer(declaration); + return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201 /* VariableStatement */: - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 205 /* VariableStatement */: + case 211 /* ForStatement */: + case 213 /* 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)) { @@ -23333,8 +24612,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23342,8 +24621,7 @@ var ts; } return false; } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); + function isUsedInFunctionOrNonStaticProperty(usage, container) { var current = usage; while (current) { if (current === container) { @@ -23353,7 +24631,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) { @@ -23386,11 +24664,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 !== 278 /* 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 */) { @@ -23399,9 +24677,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) { @@ -23413,13 +24691,13 @@ var ts; } } switch (location.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 261 /* 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"]) { @@ -23442,7 +24720,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], 243 /* ExportSpecifier */)) { break; } } @@ -23450,13 +24728,13 @@ var ts; break loop; } break; - case 225 /* EnumDeclaration */: + case 229 /* 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 @@ -23473,9 +24751,9 @@ var ts; } } break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* 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 @@ -23486,7 +24764,7 @@ var ts; } break loop; } - if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 197 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23502,9 +24780,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 === 227 /* 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); @@ -23512,19 +24790,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 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23537,7 +24815,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. // @@ -23546,7 +24824,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; } // @@ -23609,7 +24887,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 === 233 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23663,9 +24941,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23687,7 +24965,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, 223 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23708,10 +24986,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 234 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 231 /* ImportDeclaration */) { + while (node && node.kind !== 235 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23721,7 +24999,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 === 245 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -23800,31 +25078,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; } @@ -23846,19 +25124,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return getTargetOfImportClause(node); - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 235 /* ImportSpecifier */: + case 239 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 229 /* NamespaceExportDeclaration */: + case 233 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -23905,11 +25183,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236 /* ExportAssignment */) { + if (node.kind === 240 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 239 /* ExportSpecifier */) { + else if (node.kind === 243 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -23931,13 +25209,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 === 234 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -23957,9 +25235,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 === 177 /* 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; @@ -23984,30 +25262,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 @@ -24025,15 +25303,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; @@ -24166,7 +25462,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; } } @@ -24188,8 +25484,9 @@ var ts; type.intrinsicName = "boolean"; return type; } - function createObjectType(kind, symbol) { - var type = createType(kind); + function createObjectType(objectFlags, symbol) { + var type = createType(32768 /* Object */); + type.objectFlags = objectFlags; type.symbol = symbol; return type; } @@ -24217,7 +25514,7 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; @@ -24229,7 +25526,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - return setObjectTypeMembers(createObjectType(2097152 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -24241,11 +25538,11 @@ var ts; } } switch (location_1.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24286,7 +25583,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, 243 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24325,7 +25622,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, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24340,10 +25637,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; @@ -24424,7 +25721,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -24465,12 +25762,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 === 177 /* PropertyAccessExpression */ || + entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24566,10 +25863,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 === 228 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24577,7 +25874,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 /* ModuleBlock */ && + node.parent.kind === 231 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24591,10 +25888,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return "(Anonymous class)"; - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24669,9 +25966,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_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -24721,7 +26018,7 @@ var ts; } writer.writeKeyword("this"); } - else if (type.flags & 131072 /* Reference */) { + else if (getObjectFlags(type) & 4 /* Reference */) { writeTypeReference(type, nextFlags); } else if (type.flags & 256 /* EnumLiteral */) { @@ -24729,30 +26026,35 @@ var ts; writePunctuation(writer, 22 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } - else if (type.flags & (32768 /* Class */ | 65536 /* Interface */ | 16 /* Enum */ | 16384 /* TypeParameter */)) { + else if (getObjectFlags(type) & 3 /* ClassOrInterface */ || type.flags & (16 /* Enum */ | 16384 /* TypeParameter */)) { // 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 */) && ((type.flags & 2097152 /* Anonymous */ && !type.target) || type.flags & 1572864 /* UnionOrIntersection */) && type.aliasSymbol && + else if (!(flags & 512 /* InTypeAlias */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { - // We emit inferred type as type-alias at the current localtion if all the following is true - // the input type is has alias symbol that is accessible - // the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into) - // e.g.: export type Bar = () => [X, Y]; - // export type Foo = Bar; - // export const y = (x: Foo) => 1 // we want to emit as ...x: () => [any, string]) var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } - else if (type.flags & 1572864 /* UnionOrIntersection */) { + else if (type.flags & 196608 /* UnionOrIntersection */) { writeUnionOrIntersectionType(type, nextFlags); } - else if (type.flags & 2097152 /* Anonymous */) { + else if (getObjectFlags(type) & (16 /* Anonymous */ | 32 /* Mapped */)) { writeAnonymousType(type, nextFlags); } 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 // { ... } @@ -24800,7 +26102,7 @@ var ts; writePunctuation(writer, 20 /* OpenBracketToken */); writePunctuation(writer, 21 /* CloseBracketToken */); } - else if (type.target.flags & 262144 /* Tuple */) { + else if (type.target.objectFlags & 8 /* Tuple */) { writePunctuation(writer, 20 /* OpenBracketToken */); writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); writePunctuation(writer, 21 /* CloseBracketToken */); @@ -24816,14 +26118,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_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); // 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_7, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -24836,7 +26138,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 18 /* OpenParenToken */); } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); } else { @@ -24889,7 +26191,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 === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -24906,7 +26208,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 */); @@ -24924,7 +26226,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129 /* ReadonlyKeyword */); + writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -24945,6 +26247,12 @@ var ts; return false; } function writeLiteralType(type, flags) { + if (type.objectFlags & 32 /* Mapped */) { + if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { + writeMappedType(type); + return; + } + } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { @@ -24981,6 +26289,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); @@ -24993,8 +26307,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); @@ -25017,9 +26331,32 @@ var ts; writer.writeLine(); } } + } + function writeMappedType(type) { + writePunctuation(writer, 16 /* OpenBraceToken */); + writer.writeLine(); + writer.increaseIndent(); + if (type.declaration.readonlyToken) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); + writeSpace(writer); + writeKeyword(writer, 91 /* InKeyword */); + writeSpace(writer); + writeType(getConstraintTypeFromMappedType(type), 0 /* None */); + writePunctuation(writer, 21 /* CloseBracketToken */); + if (type.declaration.questionToken) { + writePunctuation(writer, 54 /* QuestionToken */); + } + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + writeType(getTemplateTypeFromMappedType(type), 0 /* None */); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); writer.decreaseIndent(); writePunctuation(writer, 17 /* CloseBraceToken */); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -25058,12 +26395,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 === 172 /* 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 === 173 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -25077,7 +26414,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 174 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55 /* ColonToken */); @@ -25207,75 +26544,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170 /* BindingElement */: + case 174 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 219 /* VariableDeclaration */: + case 223 /* 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 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 225 /* FunctionDeclaration */: + case 229 /* EnumDeclaration */: + case 234 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_8 = 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 !== 234 /* ImportEqualsDeclaration */ && parent_8.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } // 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_8); + 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 231 /* 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 236 /* ImportClause */: + case 237 /* NamespaceImport */: + case 239 /* 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 261 /* SourceFile */: + case 233 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return false; default: return false; @@ -25284,10 +26621,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 240 /* 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 === 243 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25362,7 +26699,6 @@ var ts; return getSymbolLinks(target).declaredType; } if (propertyName === 1 /* ResolvedBaseConstructorType */) { - ts.Debug.assert(!!(target.flags & 32768 /* Class */)); return target.resolvedBaseConstructorType; } if (propertyName === 3 /* ResolvedReturnType */) { @@ -25381,12 +26717,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 223 /* VariableDeclaration */: + case 224 /* VariableDeclarationList */: + case 239 /* ImportSpecifier */: + case 238 /* NamedImports */: + case 237 /* NamespaceImport */: + case 236 /* ImportClause */: node = node.parent; break; default: @@ -25419,22 +26755,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) { @@ -25454,25 +26798,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 === 172 /* 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 !== 198 /* 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 { @@ -25480,7 +26840,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) @@ -25496,10 +26860,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. @@ -25522,16 +26882,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 === 223 /* VariableDeclaration */ && + declaration.parent.kind === 224 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 205 /* 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); @@ -25547,14 +26907,14 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 175 /* 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. @@ -25564,10 +26924,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 === 212 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 209 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 213 /* 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, @@ -25581,7 +26941,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 === 223 /* 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. @@ -25594,11 +26954,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); @@ -25628,7 +26988,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 === 258 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -25659,12 +27019,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); @@ -25676,7 +27036,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; } return result; } @@ -25704,7 +27064,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 === 172 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25726,7 +27086,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 === 257 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -25743,7 +27103,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) { @@ -25755,14 +27115,14 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 252 /* CatchClause */) { + if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 236 /* ExportAssignment */) { + if (declaration.kind === 240 /* 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 === 285 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -25775,16 +27135,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 === 192 /* BinaryExpression */ || + declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* 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 === 192 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -25812,7 +27172,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 { @@ -25832,9 +27192,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; @@ -25877,7 +27237,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)); } } @@ -25888,11 +27248,11 @@ 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 { - var type = createObjectType(2097152 /* Anonymous */, symbol); + var type = createObjectType(16 /* Anonymous */, symbol); links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } @@ -25950,7 +27310,7 @@ var ts; return unknownType; } function getTargetType(type) { - return type.flags & 131072 /* Reference */ ? type.target : type; + return getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } function hasBaseType(type, checkBase) { return check(type); @@ -25984,9 +27344,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 === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || + node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25996,7 +27356,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, 227 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -26005,8 +27365,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 === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || + node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26021,7 +27381,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 2588672 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -26033,7 +27393,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; @@ -26053,7 +27413,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 2588672 /* ObjectType */) { + if (baseConstructorType.flags & 32768 /* Object */) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -26072,7 +27432,7 @@ var ts; } function getBaseTypes(type) { if (!type.resolvedBaseTypes) { - if (type.flags & 262144 /* Tuple */) { + if (type.objectFlags & 8 /* Tuple */) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { @@ -26092,7 +27452,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 2588672 /* ObjectType */)) { + if (!(baseConstructorType.flags & 32768 /* Object */)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -26119,7 +27479,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getTargetType(baseType).flags & (32768 /* Class */ | 65536 /* Interface */))) { + if (!(getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -26149,12 +27509,12 @@ 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 === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (32768 /* Class */ | 65536 /* Interface */)) { + if (getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -26181,7 +27541,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 === 227 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26204,7 +27564,7 @@ var ts; function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 32768 /* Class */ : 65536 /* Interface */; + var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -26213,8 +27573,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 32768 /* Class */ || !isIndependentInterface(symbol)) { - type.flags |= 131072 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isIndependentInterface(symbol)) { + type.objectFlags |= 4 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -26238,8 +27598,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 284 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -26250,16 +27609,17 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); - type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); + declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { - links.typeParameters = typeParameters; + var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { // Initialize the instantiation cache for generic type aliases. The declared type corresponds to // an instantiation of the type alias with the type parameters supplied as type arguments. + links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(links.typeParameters)] = type; + links.instantiations[getTypeListId(typeParameters)] = type; } } else { @@ -26276,14 +27636,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 190 /* 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 === 229 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26311,7 +27671,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 === 229 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26326,7 +27686,7 @@ var ts; } enumType.memberTypes = memberTypes; if (memberTypeList.length > 1) { - enumType.flags |= 524288 /* Union */; + enumType.flags |= 65536 /* Union */; enumType.types = memberTypeList; unionTypes[getTypeListId(memberTypeList)] = enumType; } @@ -26338,7 +27698,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - links.declaredType = enumType.flags & 524288 /* Union */ ? + links.declaredType = enumType.flags & 65536 /* Union */ ? enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : enumType; } @@ -26349,7 +27709,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; @@ -26403,19 +27763,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 171 /* LiteralType */: return true; - case 161 /* ArrayType */: + case 162 /* ArrayType */: return isIndependentType(node.elementType); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26428,7 +27788,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++) { @@ -26449,12 +27809,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); } } @@ -26499,7 +27859,7 @@ var ts; return type; } function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 131072 /* Reference */) { + if (getObjectFlags(type) & 4 /* Reference */) { return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); } return type; @@ -26522,8 +27882,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); } @@ -26543,7 +27903,7 @@ var ts; numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -26578,14 +27938,14 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNodeNoAlias); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { 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); @@ -26682,7 +28042,7 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); @@ -26690,6 +28050,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). @@ -26704,17 +28067,17 @@ var ts; stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { 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); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; @@ -26722,7 +28085,7 @@ var ts; var constructSignatures = getSignaturesOfSymbol(members["__new"]); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { // Combinations of function, class, enum and module @@ -26738,13 +28101,13 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 2588672 /* ObjectType */) { + if (baseConstructorType.flags & 32768 /* Object */) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -26754,21 +28117,95 @@ var ts; } } } + /** Resolve the members of a mapped type { [P in K]: T } */ + function resolveMappedTypeMembers(type) { + var members = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + // In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type, + // and T as the template type. + var typeParameter = getTypeParameterFromMappedType(type); + var constraintType = getConstraintTypeFromMappedType(type); + var templateType = getTemplateTypeFromMappedType(type); + var isReadonly = !!type.declaration.readonlyToken; + var isOptional = !!type.declaration.questionToken; + // First, if the constraint type is a type parameter, obtain the base constraint. Then, + // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Finally, iterate over the constituents of the resulting iteration type. + var keyType = constraintType.flags & 16384 /* TypeParameter */ ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 262144 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + forEachType(iterationType, function (t) { + // Create a mapper from T to the current iteration type constituent. Then, if the + // mapped type is itself an instantiated type, combine the iteration mapper with the + // instantiation mapper. + var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; + var propType = instantiateType(templateType, templateMapper); + // If the current iteration type constituent is a literal type, create a property. + // Otherwise, for type string create a string index signature and for type number + // create a numeric index signature. + if (t.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */)) { + var propName = t.text; + var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); + prop.type = addOptionality(propType, isOptional); + prop.isReadonly = isReadonly; + members[propName] = prop; + } + else if (t.flags & 2 /* String */) { + stringIndexInfo = createIndexInfo(propType, isReadonly); + } + else if (t.flags & 4 /* Number */) { + numberIndexInfo = createIndexInfo(propType, isReadonly); + } + }); + // If we created both a string and a numeric string index signature, and if the two index + // signatures have identical types, discard the redundant numeric index signature. + if (stringIndexInfo && numberIndexInfo && isTypeIdenticalTo(stringIndexInfo.type, numberIndexInfo.type)) { + numberIndexInfo = undefined; + } + setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } + function getTypeParameterFromMappedType(type) { + return type.typeParameter || + (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter))); + } + function getConstraintTypeFromMappedType(type) { + return type.constraintType || + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + } + function getTemplateTypeFromMappedType(type) { + return type.templateType || + (type.templateType = type.declaration.type ? + instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + unknownType); + } + function isGenericMappedType(type) { + if (getObjectFlags(type) & 32 /* Mapped */) { + var constraintType = getConstraintTypeFromMappedType(type); + return !!(constraintType.flags & (16384 /* TypeParameter */ | 262144 /* Index */)); + } + return false; + } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Reference */) { - resolveTypeReferenceMembers(type); + if (type.flags & 32768 /* Object */) { + if (type.objectFlags & 4 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.objectFlags & 3 /* ClassOrInterface */) { + resolveClassOrInterfaceMembers(type); + } + else if (type.objectFlags & 16 /* Anonymous */) { + resolveAnonymousTypeMembers(type); + } + else if (type.objectFlags & 32 /* Mapped */) { + resolveMappedTypeMembers(type); + } } - else if (type.flags & (32768 /* Class */ | 65536 /* Interface */)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 2097152 /* Anonymous */) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 524288 /* Union */) { + else if (type.flags & 65536 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 1048576 /* Intersection */) { + else if (type.flags & 131072 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -26776,7 +28213,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return emptyArray; @@ -26784,7 +28221,7 @@ var ts; /** If the given type is an object type and that type has a property by the given name, * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -26801,7 +28238,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { break; } } @@ -26821,7 +28258,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 1572864 /* 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 @@ -26843,28 +28282,19 @@ 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; var props; // Flags we want to propagate to the result if they exist in all source symbols - var commonFlags = (containingType.flags & 1048576 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; + var commonFlags = (containingType.flags & 131072 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; var isReadonly = false; var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { @@ -26884,7 +28314,7 @@ var ts; isReadonly = true; } } - else if (containingType.flags & 524288 /* Union */) { + else if (containingType.flags & 65536 /* Union */) { isPartial = true; } } @@ -26919,7 +28349,7 @@ var ts; result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; - result.type = containingType.flags & 524288 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = containingType.flags & 65536 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -26953,7 +28383,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -26967,13 +28397,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 1572864 /* UnionOrIntersection */) { + if (type.flags & 196608 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 4161536 /* StructuredType */) { + if (type.flags & 229376 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -26987,7 +28417,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 4161536 /* StructuredType */) { + if (type.flags & 229376 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -27022,7 +28452,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); @@ -27052,8 +28482,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 === 273 /* JSDocOptionalType */) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -27062,11 +28492,19 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 273 /* 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; @@ -27124,7 +28562,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167 /* LiteralType */) { + if (param.type && param.type.kind === 171 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -27138,10 +28576,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); @@ -27153,14 +28591,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); @@ -27177,7 +28615,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; @@ -27185,8 +28623,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)) { @@ -27200,20 +28638,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 225 /* 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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 274 /* 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). @@ -27277,13 +28715,18 @@ var ts; function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 131072 /* Reference */ && type.target === globalArrayType) { + if (getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } } 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) { @@ -27300,8 +28743,8 @@ 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 type = createObjectType(2097152 /* Anonymous */); + var isConstructor = signature.declaration.kind === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; + var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -27314,7 +28757,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++) { @@ -27341,7 +28784,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; @@ -27374,7 +28817,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 = ""; @@ -27411,22 +28854,23 @@ var ts; result |= type.flags; } } - return result & 234881024 /* PropagatingFlags */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var propagatedFlags = typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; - var flags = 131072 /* Reference */ | propagatedFlags; - type = target.instantiations[id] = createObjectType(flags, target.symbol); + type = target.instantiations[id] = createObjectType(4 /* Reference */, target.symbol); + type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; } return type; } function cloneTypeReference(source) { - var type = createObjectType(source.flags, source.symbol); + var type = createType(source.flags); + type.symbol = source.symbol; + type.objectFlags = source.objectFlags; type.target = source.target; type.typeArguments = source.typeArguments; return type; @@ -27446,7 +28890,7 @@ var ts; // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias))); + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -27454,21 +28898,26 @@ var ts; } return type; } + function getTypeAliasInstantiation(symbol, typeArguments) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the // declared type. Instantiations are cached using the type identities of the type arguments as the key. function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); - var links = getSymbolLinks(symbol); - var typeParameters = links.typeParameters; + var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); return unknownType; } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + return getTypeAliasInstantiation(symbol, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); @@ -27486,11 +28935,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156 /* TypeReference */: + case 157 /* TypeReference */: return node.typeName; - case 267 /* JSDocTypeReference */: + case 272 /* JSDocTypeReference */: return node.name; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27516,7 +28965,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 === 272 /* 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. @@ -27529,14 +28978,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267 /* JSDocTypeReference */) { + if (node.kind === 272 /* 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 @@ -27571,9 +29020,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: return declaration; } } @@ -27582,7 +29031,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 2588672 /* ObjectType */)) { + if (!(type.flags & 32768 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -27662,7 +29111,7 @@ var ts; property.type = typeParameter; properties.push(property); } - var type = createObjectType(262144 /* Tuple */ | 131072 /* Reference */); + var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -27689,7 +29138,7 @@ var ts; function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNodeNoAlias)); + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); } return links.resolvedType; } @@ -27717,7 +29166,7 @@ var ts; } function addTypeToUnion(typeSet, type) { var flags = type.flags; - if (flags & 524288 /* Union */) { + if (flags & 65536 /* Union */) { addTypesToUnion(typeSet, type.types); } else if (flags & 1 /* Any */) { @@ -27728,7 +29177,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096 /* Null */) typeSet.containsNull = true; - if (!(flags & 33554432 /* ContainsWideningType */)) + if (!(flags & 2097152 /* ContainsWideningType */)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192 /* Never */)) { @@ -27741,7 +29190,8 @@ var ts; var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & 2097152 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { + if (!(flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } } @@ -27805,7 +29255,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 & 16777216 /* FreshLiteral */ && containsType(types, t.regularType); + t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 1048576 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -27855,22 +29305,22 @@ var ts; var type = unionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */); - type = unionTypes[id] = createObjectType(524288 /* Union */ | propagatedFlags); + type = unionTypes[id] = createType(65536 /* Union */ | propagatedFlags); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*subtypeReduction*/ false, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } function addTypeToIntersection(typeSet, type) { - if (type.flags & 1048576 /* Intersection */) { + if (type.flags & 131072 /* Intersection */) { addTypesToIntersection(typeSet, type.types); } else if (type.flags & 1 /* Any */) { @@ -27888,6 +29338,11 @@ var ts; addTypeToIntersection(typeSet, type); } } + // We normalize combinations of intersection and union types based on the distributive property of the '&' + // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection + // types with union type constituents into equivalent union types with intersection type constituents and + // effectively ensure that union types are always at the top level in type representations. + // // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. @@ -27897,6 +29352,18 @@ var ts; if (types.length === 0) { return emptyObjectType; } + 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)); }), + /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments) }; + } + }; + for (var i = 0; i < types.length; i++) { + var state_2 = _loop_2(i); + if (typeof state_2 === "object") + return state_2.value; + } var typeSet = []; addTypesToIntersection(typeSet, types); if (typeSet.containsAny) { @@ -27909,40 +29376,256 @@ var ts; var type = intersectionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 6144 /* Nullable */); - type = intersectionTypes[id] = createObjectType(1048576 /* Intersection */ | propagatedFlags); + type = intersectionTypes[id] = createType(131072 /* Intersection */ | propagatedFlags); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), aliasSymbol, aliasTypeArguments); + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144 /* Index */); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */ || 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) { - // Deferred resolution of members is handled by resolveObjectTypeMembers - var type = createObjectType(2097152 /* Anonymous */, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = getIndexType(getTypeFromTypeNode(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 === 178 /* 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 === 178 /* 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 (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + 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(getTypeFromTypeNode(node.objectType), getTypeFromTypeNode(node.indexType), node); + } + return links.resolvedType; + } + function getTypeFromMappedTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = createObjectType(32 /* Mapped */, node.symbol); + type.declaration = node; + type.aliasSymbol = getAliasSymbolForTypeNode(node); + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); links.resolvedType = type; } return links.resolvedType; } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // Deferred resolution of members is handled by resolveObjectTypeMembers + var aliasSymbol = getAliasSymbolForTypeNode(node); + if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16 /* Anonymous */, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + links.resolvedType = type; + } + } + return links.resolvedType; + } + function getAliasSymbolForTypeNode(node) { + return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + } + function getAliasTypeArgumentsForTypeNode(node) { + var symbol = getAliasSymbolForTypeNode(node); + return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; + } + /** + * 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 & 16777216 /* FreshLiteral */)) { + if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 1048576 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 16777216 /* FreshLiteral */, type.text); + var freshType = createLiteralType(type.flags | 1048576 /* FreshLiteral */, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -27951,7 +29634,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 16777216 /* 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; @@ -27975,7 +29658,7 @@ var ts; function getTypeFromJSDocTupleType(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var types = ts.map(node.types, getTypeFromTypeNodeNoAlias); + var types = ts.map(node.types, getTypeFromTypeNode); links.resolvedType = createTupleType(types); } return links.resolvedType; @@ -27983,9 +29666,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 === 227 /* 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; } } @@ -27999,87 +29682,90 @@ var ts; } return links.resolvedType; } - function getTypeFromTypeNodeNoAlias(type) { - return getTypeFromTypeNode(type, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined); - } - function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 258 /* JSDocAllType */: - case 259 /* JSDocUnknownType */: + case 263 /* JSDocAllType */: + case 264 /* 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 288 /* JSDocNullKeyword */: return nullType; - case 284 /* JSDocUndefinedKeyword */: + case 289 /* JSDocUndefinedKeyword */: return undefinedType; - case 285 /* JSDocNeverKeyword */: + case 290 /* JSDocNeverKeyword */: return neverType; - case 166 /* ThisType */: + case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 167 /* LiteralType */: + case 171 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 282 /* JSDocLiteralType */: + case 287 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 156 /* TypeReference */: - case 267 /* JSDocTypeReference */: + case 157 /* TypeReference */: + case 272 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return booleanType; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 161 /* ArrayType */: - case 260 /* JSDocArrayType */: + case 162 /* ArrayType */: + case 265 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 163 /* UnionType */: - case 261 /* JSDocUnionType */: - return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* 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 164 /* UnionType */: + case 266 /* JSDocUnionType */: + return getTypeFromUnionTypeNode(node); + case 165 /* IntersectionType */: + return getTypeFromIntersectionTypeNode(node); + case 166 /* ParenthesizedType */: + case 268 /* JSDocNullableType */: + case 269 /* JSDocNonNullableType */: + case 276 /* JSDocConstructorType */: + case 277 /* JSDocThisType */: + case 273 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 265 /* JSDocRecordType */: + case 270 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 269 /* JSDocFunctionType */: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 161 /* TypeLiteral */: + case 286 /* JSDocTypeLiteral */: + case 274 /* JSDocFunctionType */: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 168 /* TypeOperator */: + return getTypeFromTypeOperatorNode(node); + case 169 /* IndexedAccessType */: + return getTypeFromIndexedAccessTypeNode(node); + case 170 /* MappedType */: + return getTypeFromMappedTypeNode(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 267 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 270 /* JSDocVariadicType */: + case 275 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -28096,6 +29782,16 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } + function instantiateCached(type, mapper, instantiator) { + var instantiations = mapper.instantiations || (mapper.instantiations = []); + return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -28118,7 +29814,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) { @@ -28216,25 +29911,25 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - var result = createObjectType(2097152 /* Anonymous */ | 4194304 /* Instantiated */, type.symbol); - result.target = type; - result.mapper = mapper; + var result = createObjectType(16 /* Anonymous */ | 64 /* Instantiated */, type.symbol); + result.target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; + result.mapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; - mapper.instantiations[type.id] = result; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + return result; + } + function instantiateMappedType(type, mapper) { + var result = createObjectType(32 /* Mapped */ | 64 /* Instantiated */, type.symbol); + result.declaration = type.declaration; + result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + result.aliasSymbol = type.aliasSymbol; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); 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 @@ -28242,23 +29937,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 225 /* 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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28268,27 +29963,63 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226 /* ModuleDeclaration */: - case 256 /* SourceFile */: + case 230 /* ModuleDeclaration */: + case 261 /* SourceFile */: return false; } node = node.parent; } return false; } + function isTopLevelTypeAlias(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var parentKind = symbol.declarations[0].parent.kind; + return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + } + return false; + } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.flags & 16384 /* TypeParameter */) { - return mapper(type); + // If we are instantiating a type that has a top-level type alias, obtain the instantiation through + // the type alias instead in order to share instantiations for the same type arguments. This can + // dramatically reduce the number of structurally identical types we generate. Note that we can only + // perform this optimization for top-level type aliases. Consider: + // + // function f1(x: T) { + // type Foo = { x: X, t: T }; + // let obj: Foo = { x: x }; + // return obj; + // } + // function f2(x: U) { return f1(x); } + // let z = f2(42); + // + // Above, the declaration of f2 has an inferred return type that is an instantiation of f1's Foo + // equivalent to { x: U, t: U }. When instantiating this return type, we can't go back to Foo's + // cache because all cached instantiations are of the form { x: ???, t: T }, i.e. they have not been + // instantiated for T. Instead, we need to further instantiate the { x: U, t: U } form. + if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { + if (type.aliasTypeArguments) { + return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + return type; } - if (type.flags & 2097152 /* Anonymous */) { + return instantiateTypeNoAlias(type, mapper); + } + return type; + } + function instantiateTypeNoAlias(type, mapper) { + if (type.flags & 16384 /* TypeParameter */) { + return mapper(type); + } + if (type.flags & 32768 /* Object */) { + if (type.objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. We skip instantiation @@ -28297,19 +30028,28 @@ var ts; // instantiation. return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && - (type.flags & 4194304 /* Instantiated */ || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateAnonymousType(type, mapper) : type; + (type.objectFlags & 64 /* Instantiated */ || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? + instantiateCached(type, mapper, instantiateAnonymousType) : type; } - if (type.flags & 131072 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + if (type.objectFlags & 32 /* Mapped */) { + return instantiateCached(type, mapper, instantiateMappedType); } - if (type.flags & 524288 /* Union */ && !(type.flags & 8190 /* Primitive */)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); - } - if (type.flags & 1048576 /* Intersection */) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + if (type.objectFlags & 4 /* Reference */) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } + if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { + return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 131072 /* Intersection */) { + 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; } function instantiateIndexInfo(info, mapper) { @@ -28318,27 +30058,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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -28353,7 +30093,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 185 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -28367,10 +30107,10 @@ var ts; return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(2097152 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -28573,7 +30313,7 @@ var ts; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256 /* RegularEnum */) || !(target.symbol.flags & 256 /* RegularEnum */) || - (source.flags & 524288 /* Union */) !== (target.flags & 524288 /* Union */)) { + (source.flags & 65536 /* Union */) !== (target.flags & 65536 /* Union */)) { return enumRelation[id] = false; } var targetEnumType = getTypeOfSymbol(target.symbol); @@ -28630,23 +30370,23 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 16777216 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 16777216 /* FreshLiteral */) { + if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 1048576 /* FreshLiteral */) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 2588672 /* ObjectType */ && target.flags & 2588672 /* ObjectType */) { + if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 4177920 /* StructuredOrTypeParameter */ || target.flags & 4177920 /* StructuredOrTypeParameter */) { + if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -28693,9 +30433,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); } @@ -28715,10 +30461,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 & 16777216 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 16777216 /* 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 @@ -28729,7 +30475,13 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (source.flags & 8388608 /* ObjectLiteral */ && source.flags & 16777216 /* FreshLiteral */) { + if (source.flags & 262144 /* Index */) { + // A keyof T is related to a union type containing both string and number + if (maybeTypeOfKind(target, 2 /* String */) && maybeTypeOfKind(target, 4 /* Number */)) { + return -1 /* True */; + } + } + if (getObjectFlags(source) & 128 /* ObjectLiteral */ && source.flags & 1048576 /* FreshLiteral */) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -28740,13 +30492,15 @@ var ts; // and intersection types are further deconstructed on the target side, we don't want to // make the check again (as it might fail for a partial target type). Therefore we obtain // the regular source type and proceed with that. - if (target.flags & 1572864 /* UnionOrIntersection */) { + if (target.flags & 196608 /* UnionOrIntersection */) { source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - // Note that these checks are specifically ordered to produce correct results. - if (source.flags & 524288 /* Union */) { + // Note that these checks are specifically ordered to produce correct results. In particular, + // we need to deconstruct unions before intersections (because unions are always at the top), + // and we need to handle "each" relations before "some" relations for the same kind of type. + if (source.flags & 65536 /* Union */) { if (relation === comparableRelation) { result = someTypeRelatedToType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */)); } @@ -28757,36 +30511,56 @@ var ts; return result; } } - else if (target.flags & 1048576 /* Intersection */) { - result = typeRelatedToEachType(source, target, reportErrors); - if (result) { + else if (target.flags & 65536 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { return result; } } - else { - // It is necessary to try these "some" checks on both sides because there may be nested "each" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 1048576 /* Intersection */) { - // Check to see if any constituents of the intersection are immediately related to the target. - // - // Don't report errors though. Checking whether a constituent is related to the source is not actually - // useful and leads to some confusing error messages. Instead it is better to let the below checks - // take care of this, or to not elaborate at all. For instance, - // - // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. - // - // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection - // than to report that 'D' is not assignable to 'A' or 'B'. - // - // - For a primitive type or type parameter (such as 'number = A & B') there is no point in - // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + else if (target.flags & 131072 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072 /* Intersection */) { + // Check to see if any constituents of the intersection are immediately related to the target. + // + // Don't report errors though. Checking whether a constituent is related to the source is not actually + // useful and leads to some confusing error messages. Instead it is better to let the below checks + // take care of this, or to not elaborate at all. For instance, + // + // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. + // + // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection + // than to report that 'D' is not assignable to 'A' or 'B'. + // + // - For a primitive type or type parameter (such as 'number = A & B') there is no point in + // breaking the intersection apart. + if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + 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; } } - if (target.flags & 524288 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { + } + else if (target.flags & 262144 /* Index */) { + // A keyof S is related to a keyof T if T is related to S. + if (source.flags & 262144 /* Index */) { + if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { + return result; + } + } + // 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; } } @@ -28806,32 +30580,43 @@ var ts; } } else { - if (source.flags & 131072 /* Reference */ && target.flags & 131072 /* Reference */ && source.target === target.target) { + if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - var apparentSource = getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (apparentSource.flags & (2588672 /* ObjectType */ | 1048576 /* Intersection */) && target.flags & 2588672 /* ObjectType */) { - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190 /* Primitive */); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; + if (isGenericMappedType(target)) { + // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + if (isGenericMappedType(source)) { + if ((result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) && + (result = isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors))) { + return result; + } + } + } + else { + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentSource = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentSource.flags & (32768 /* Object */ | 131072 /* Intersection */) && target.flags & 32768 /* Object */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190 /* Primitive */); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } if (reportErrors) { - if (source.flags & 2588672 /* ObjectType */ && target.flags & 8190 /* Primitive */) { + if (source.flags & 32768 /* Object */ && target.flags & 8190 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 2588672 /* ObjectType */ && globalObjectType === source) { + else if (source.symbol && source.flags & 32768 /* Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } reportRelationError(headMessage, source, target); @@ -28840,8 +30625,8 @@ var ts; } function isIdenticalTo(source, target) { var result; - if (source.flags & 2588672 /* ObjectType */ && target.flags & 2588672 /* ObjectType */) { - if (source.flags & 131072 /* Reference */ && target.flags & 131072 /* Reference */ && source.target === target.target) { + if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { + if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if all type arguments are identical if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; @@ -28849,8 +30634,8 @@ var ts; } return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); } - if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ || - source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { + if (source.flags & 65536 /* Union */ && target.flags & 65536 /* Union */ || + source.flags & 131072 /* Intersection */ && target.flags & 131072 /* Intersection */) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -28864,7 +30649,7 @@ var ts; // index signatures, or if the property is actually declared in the object type. In a union or intersection // type, a property is considered known if it is known in any constituent type. function isKnownProperty(type, name) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || @@ -28873,7 +30658,7 @@ var ts; return true; } } - else if (type.flags & 1572864 /* UnionOrIntersection */) { + else if (type.flags & 196608 /* UnionOrIntersection */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name)) { @@ -28891,8 +30676,7 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (maybeTypeOfKind(target, 2588672 /* ObjectType */) && - (!(target.flags & 2588672 /* ObjectType */) || !target.isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -28925,7 +30709,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 524288 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 65536 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } var len = targetTypes.length; @@ -28952,7 +30736,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 524288 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 65536 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -29083,9 +30867,9 @@ var ts; } var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 8388608 /* ObjectLiteral */); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); + 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) { @@ -29137,7 +30921,8 @@ var ts; return 0 /* False */; } result &= related; - if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + // When checking for comparability, be more lenient with optional properties. + if (relation !== comparableRelation && sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -29156,7 +30941,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 2588672 /* ObjectType */ && target.flags & 2588672 /* ObjectType */)) { + if (!(source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -29341,7 +31126,7 @@ var ts; } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { - if (type.flags & 2097152 /* Anonymous */) { + if (getObjectFlags(type) & 16 /* Anonymous */) { var symbol = type.symbol; if (symbol && symbol.flags & 32 /* Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); @@ -29359,12 +31144,12 @@ var ts; // some level beyond that. function isDeeplyNestedGeneric(type, stack, depth) { // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (131072 /* Reference */ | 4194304 /* Instantiated */) && depth >= 5) { + if (getObjectFlags(type) & (4 /* Reference */ | 64 /* Instantiated */) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (131072 /* Reference */ | 4194304 /* Instantiated */) && t.symbol === symbol) { + if (getObjectFlags(t) & (4 /* Reference */ | 64 /* Instantiated */) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -29550,12 +31335,12 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isArrayType(type) { - return type.flags & 131072 /* Reference */ && type.target === globalArrayType; + return getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return type.flags & 131072 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + return getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || !(type.flags & 6144 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { @@ -29566,7 +31351,7 @@ var ts; } function isLiteralType(type) { return type.flags & 8 /* Boolean */ ? true : - type.flags & 524288 /* Union */ ? type.flags & 16 /* Enum */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + type.flags & 65536 /* Union */ ? type.flags & 16 /* Enum */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { @@ -29574,15 +31359,15 @@ var ts; type.flags & 64 /* NumberLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 32 /* StringLiteral */ && type.flags & 16777216 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 16777216 /* 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 & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } /** @@ -29590,7 +31375,7 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ function isTupleType(type) { - return !!(type.flags & 131072 /* Reference */ && type.target.flags & 262144 /* Tuple */); + return !!(getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getFalsyFlagsOfTypes(types) { var result = 0; @@ -29604,7 +31389,7 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 524288 /* Union */ ? getFalsyFlagsOfTypes(type.types) : + return type.flags & 65536 /* Union */ ? getFalsyFlagsOfTypes(type.types) : type.flags & 32 /* StringLiteral */ ? type.text === "" ? 32 /* StringLiteral */ : 0 : type.flags & 64 /* NumberLiteral */ ? type.text === "0" ? 64 /* NumberLiteral */ : 0 : type.flags & 128 /* BooleanLiteral */ ? type === falseType ? 128 /* BooleanLiteral */ : 0 : @@ -29674,7 +31459,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(type.flags & 8388608 /* ObjectLiteral */ && type.flags & 16777216 /* FreshLiteral */)) { + if (!(getObjectFlags(type) & 128 /* ObjectLiteral */ && type.flags & 1048576 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -29684,7 +31469,8 @@ 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 & ~16777216 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~1048576 /* FreshLiteral */; + regularNew.objectFlags |= 128 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; } @@ -29701,14 +31487,14 @@ var ts; return type.flags & 6144 /* Nullable */ ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 100663296 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & 6144 /* Nullable */) { return anyType; } - if (type.flags & 8388608 /* ObjectLiteral */) { + if (getObjectFlags(type) & 128 /* ObjectLiteral */) { return getWidenedTypeOfObjectLiteral(type); } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { @@ -29730,7 +31516,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (reportWideningErrorsInType(t)) { @@ -29746,11 +31532,11 @@ var ts; } } } - if (type.flags & 8388608 /* ObjectLiteral */) { + if (getObjectFlags(type) & 128 /* ObjectLiteral */) { for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 33554432 /* 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))); } @@ -29764,25 +31550,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 174 /* 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 225 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29795,7 +31581,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 33554432 /* 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); @@ -29843,10 +31629,12 @@ var ts; // we perform type inference (i.e. a type parameter of a generic function). We cache // results for union and intersection types for performance reasons. function couldContainTypeParameters(type) { + var objectFlags = getObjectFlags(type); return !!(type.flags & 16384 /* TypeParameter */ || - type.flags & 131072 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) || - type.flags & 2097152 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || - type.flags & 1572864 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type)); + objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || + objectFlags & 32 /* Mapped */ || + type.flags & 196608 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type)); } function couldUnionOrIntersectionContainTypeParameters(type) { if (type.couldContainTypeParameters === undefined) { @@ -29855,7 +31643,7 @@ var ts; return type.couldContainTypeParameters; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 1572864 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || type.flags & 196608 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function inferTypes(context, originalSource, originalTarget) { var typeParameters = context.signature.typeParameters; @@ -29877,8 +31665,18 @@ var ts; if (!couldContainTypeParameters(target)) { return; } - if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ && !(source.flags & 16 /* Enum */ && target.flags & 16 /* Enum */) || - source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { + if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + var sourceTypes = source.aliasTypeArguments; + var targetTypes = target.aliasTypeArguments; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + return; + } + if (source.flags & 65536 /* Union */ && target.flags & 65536 /* Union */ && !(source.flags & 16 /* Enum */ && target.flags & 16 /* Enum */) || + source.flags & 131072 /* Intersection */ && target.flags & 131072 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -29923,7 +31721,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 & 134217728 /* ContainsAnyFunctionType */) { + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -29950,7 +31748,7 @@ var ts; } } } - else if (source.flags & 131072 /* Reference */ && target.flags & 131072 /* Reference */ && source.target === target.target) { + else if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments var sourceTypes = source.typeArguments || emptyArray; var targetTypes = target.typeArguments || emptyArray; @@ -29959,7 +31757,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 1572864 /* UnionOrIntersection */) { + else if (target.flags & 196608 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter = void 0; @@ -29983,7 +31781,7 @@ var ts; inferiority--; } } - else if (source.flags & 1572864 /* UnionOrIntersection */) { + else if (source.flags & 196608 /* UnionOrIntersection */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -29992,8 +31790,21 @@ var ts; } } else { + if (getObjectFlags(target) & 32 /* Mapped */) { + var constraintType = getConstraintTypeFromMappedType(target); + if (getObjectFlags(source) & 32 /* Mapped */) { + inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + return; + } + if (constraintType.flags & 16384 /* TypeParameter */) { + inferFromTypes(getIndexType(source), constraintType); + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return; + } + } source = getApparentType(source); - if (source.flags & 2588672 /* ObjectType */) { + if (source.flags & 32768 /* Object */) { if (isInProcess(source, target)) { return; } @@ -30022,8 +31833,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)); @@ -30093,7 +31904,7 @@ var ts; reducedTypes.push(t); } } - return type.flags & 524288 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 65536 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function getInferenceCandidates(context, index) { var inferences = context.inferences[index]; @@ -30101,7 +31912,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]; @@ -30171,10 +31982,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: @@ -30195,7 +32006,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 173 /* PropertyAccessExpression */) { + if (node.kind === 177 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30206,7 +32017,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -30215,19 +32026,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 === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 173 /* PropertyAccessExpression */: - return target.kind === 173 /* PropertyAccessExpression */ && + case 177 /* PropertyAccessExpression */: + return target.kind === 177 /* 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 === 177 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30240,7 +32051,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 === 177 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -30248,14 +32059,14 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173 /* PropertyAccessExpression */) { + if (expr.kind === 177 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 524288 /* Union */) { + if (type && type.flags & 65536 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -30278,7 +32089,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 177 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30292,7 +32103,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 524288 /* Union */)) { + if (!(source.flags & 65536 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -30360,7 +32171,7 @@ var ts; type === falseType ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : type === falseType ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; } - if (flags & 2588672 /* ObjectType */) { + if (flags & 32768 /* Object */) { return isFunctionObjectType(type) ? strictNullChecks ? 6164448 /* FunctionStrictFacts */ : 8376288 /* FunctionFacts */ : strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; @@ -30378,7 +32189,7 @@ var ts; var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); } - if (flags & 1572864 /* UnionOrIntersection */) { + if (flags & 196608 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } return 8388607 /* All */; @@ -30394,7 +32205,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 */) || @@ -30405,19 +32216,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 === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* 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); @@ -30428,21 +32239,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return stringType; - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return undefinedType; - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192 /* SpreadElementExpression */: - return getAssignedTypeOfSpreadElement(parent); - case 253 /* PropertyAssignment */: + case 196 /* SpreadElement */: + return getAssignedTypeOfSpreadExpression(parent); + case 257 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -30450,11 +32261,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 === 172 /* 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) { @@ -30468,35 +32279,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208 /* ForInStatement */) { + if (node.parent.parent.kind === 212 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.parent.kind === 213 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 /* VariableDeclaration */ ? + return node.kind === 223 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? + return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 /* VariableDeclaration */ && node.initializer && + return node.kind === 223 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -30508,13 +32319,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 === 183 /* ParenthesizedExpression */ || + parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249 /* CaseClause */) { + if (clause.kind === 253 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -30531,13 +32342,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 524288 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 65536 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 524288 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 65536 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 524288 /* Union */) { + if (source.flags & 65536 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -30551,8 +32362,11 @@ var ts; } return containsType(target.types, source); } + function forEachType(type, f) { + return type.flags & 65536 /* Union */ ? ts.forEach(type.types, f) : f(type); + } function filterType(type, f) { - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered); @@ -30560,7 +32374,7 @@ var ts; return f(type) ? type : neverType; } function mapType(type, f) { - return type.flags & 524288 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); + return type.flags & 65536 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -30593,7 +32407,7 @@ var ts; // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(2097152 /* Anonymous */); + var result = createObjectType(256 /* EvolvingArray */); result.elementType = elementType; return result; } @@ -30607,13 +32421,10 @@ var ts; var elementType = getBaseTypeOfLiteralType(checkExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } - function isEvolvingArrayType(type) { - return !!(type.flags & 2097152 /* Anonymous */ && type.elementType); - } function createFinalArrayType(elementType) { return elementType.flags & 8192 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 524288 /* Union */ ? + createArrayType(elementType.flags & 65536 /* Union */ ? getUnionType(elementType.types, /*subtypeReduction*/ true) : elementType); } @@ -30622,17 +32433,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? type.elementType : neverType; + return getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { var t = types_12[_i]; if (!(t.flags & 8192 /* Never */)) { - if (!isEvolvingArrayType(t)) { + if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -30653,20 +32464,40 @@ 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 === 177 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 179 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 178 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.kind === 192 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); return isLengthPushOrUnshift || isElementAssignment; } + function maybeTypePredicateCall(node) { + var links = getNodeLinks(node); + if (links.maybeTypePredicate === undefined) { + links.maybeTypePredicate = getMaybeTypePredicate(node); + } + return links.maybeTypePredicate; + } + function getMaybeTypePredicate(node) { + if (node.expression.kind !== 96 /* SuperKeyword */) { + var funcType = checkNonNullExpression(node.expression); + if (funcType !== silentNeverType) { + var apparentType = getApparentType(funcType); + if (apparentType !== unknownType) { + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + return !!ts.forEach(callSignatures, function (sig) { return sig.typePredicate; }); + } + } + } + return false; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -30679,8 +32510,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 201 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -30729,7 +32560,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 !== 177 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30755,7 +32586,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)); } @@ -30766,7 +32597,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 524288 /* Union */) { + if (declaredType.flags & 65536 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -30783,15 +32614,15 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 /* CallExpression */ ? + var expr = node.kind === 179 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (isEvolvingArrayType(type)) { + if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 175 /* CallExpression */) { + if (node.kind === 179 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -30946,8 +32777,8 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 /* PropertyAccessExpression */ && - declaredType.flags & 524288 /* Union */ && + return expr.kind === 177 /* PropertyAccessExpression */ && + declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); } @@ -30980,10 +32811,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 === 187 /* 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 === 187 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -31029,7 +32860,7 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 2589185 /* NotUnionOrUnit */) { + if (type.flags & 33281 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { @@ -31056,7 +32887,7 @@ var ts; if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 524288 /* Union */)) { + if (assumeTrue && !(type.flags & 65536 /* Union */)) { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. @@ -31118,10 +32949,10 @@ var ts; if (!targetType) { // Target type is type of construct signature var constructSignatures = void 0; - if (rightType.flags & 65536 /* Interface */) { + if (getObjectFlags(rightType) & 2 /* Interface */) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 2097152 /* Anonymous */) { + else if (getObjectFlags(rightType) & 16 /* Anonymous */) { constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); } if (constructSignatures && constructSignatures.length) { @@ -31139,7 +32970,7 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var assignableType = filterType(type, function (t) { return isTypeInstanceOf(t, candidate); }); if (!(assignableType.flags & 8192 /* Never */)) { return assignableType; @@ -31157,7 +32988,7 @@ var ts; getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { return type; } var signature = getResolvedSignature(callExpression); @@ -31181,10 +33012,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 === 178 /* ElementAccessExpression */ || invokedExpression.kind === 177 /* 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); } @@ -31201,15 +33032,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -31241,19 +33072,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 === 231 /* ModuleBlock */ || + node.kind === 261 /* SourceFile */ || + node.kind === 147 /* PropertyDeclaration */) { return node; } } @@ -31285,7 +33110,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; } } @@ -31299,6 +33124,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 @@ -31308,16 +33136,17 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 185 /* 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); @@ -31329,7 +33158,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 === 226 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31341,14 +33170,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193 /* ClassExpression */) { + else if (declaration_1.kind === 197 /* 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 */; } @@ -31363,23 +33192,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 === 184 /* FunctionExpression */ || + flowContainer.kind === 185 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -31407,7 +33247,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; @@ -31422,7 +33262,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 === 256 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -31447,8 +33287,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 === 211 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31462,7 +33302,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 179 /* ParenthesizedExpression */) { + while (current.parent.kind === 183 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31470,7 +33310,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 === 190 /* PrefixUnaryExpression */ || current.parent.kind === 191 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -31491,7 +33331,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 */; } @@ -31539,7 +33379,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 @@ -31560,32 +33400,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 185 /* 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 230 /* 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 229 /* 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; } @@ -31597,7 +33437,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 === 184 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31634,28 +33474,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 === 274 /* 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 === 277 /* 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 === 179 /* 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 === 185 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -31669,16 +33509,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 === 176 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31749,7 +33589,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 */; } @@ -31763,7 +33603,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 === 176 /* 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; @@ -31783,7 +33623,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; @@ -31798,7 +33638,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) @@ -31806,21 +33646,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 === 176 /* 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 */; } } } @@ -31828,7 +33668,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -31894,7 +33734,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; @@ -31905,11 +33745,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); } @@ -31946,7 +33786,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; @@ -31957,8 +33797,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 @@ -31980,7 +33820,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177 /* TaggedTemplateExpression */) { + if (template.parent.kind === 181 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -32018,7 +33858,7 @@ var ts; // is a union type, the mapping function is applied to each constituent type and a union of the resulting // types is returned. function applyToContextualType(type, mapper) { - if (!(type.flags & 524288 /* Union */)) { + if (!(type.flags & 65536 /* Union */)) { return mapper(type); } var types = type.types; @@ -32043,7 +33883,7 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = t.flags & 4161536 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 229376 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } @@ -32052,7 +33892,7 @@ var ts; } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 524288 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 65536 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -32108,13 +33948,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246 /* JsxAttribute */) { + if (attribute.kind === 250 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247 /* JsxSpreadAttribute */) { + else if (attribute.kind === 251 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -32152,58 +33992,73 @@ 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 223 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 174 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 181 /* ArrowFunction */: - case 212 /* ReturnStatement */: + case 185 /* ArrowFunction */: + case 216 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 198 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); + case 202 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return getContextualType(parent); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return getContextualType(parent); - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxAttribute */: + case 251 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; } // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. - function getNonGenericSignature(type) { + function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); if (signatures.length === 1) { var signature = signatures[0]; - if (!signature.typeParameters) { + if (!signature.typeParameters && !isAritySmaller(signature, node)) { return signature; } } } + /** If the contextual signature has fewer parameters than the function expression, do not use it */ + function isAritySmaller(signature, target) { + var targetParameterCount = 0; + for (; targetParameterCount < target.parameters.length; targetParameterCount++) { + var param = target.parameters[targetParameterCount]; + if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { + break; + } + } + if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { + targetParameterCount--; + } + var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; + return sourceLength < targetParameterCount; + } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; + return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -32222,19 +34077,19 @@ 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; } - if (!(type.flags & 524288 /* Union */)) { - return getNonGenericSignature(type); + if (!(type.flags & 65536 /* Union */)) { + return getNonGenericSignature(type, node); } var signatureList; var types = type.types; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var current = types_14[_i]; - var signature = getNonGenericSignature(current); + var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature @@ -32278,7 +34133,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 @@ -32289,8 +34144,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 === 174 /* BindingElement */ && !!node.initializer) || + (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -32299,7 +34154,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 === 196 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32323,7 +34178,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 196 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32338,7 +34193,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 === 173 /* ArrayBindingPattern */ || pattern.kind === 175 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32346,7 +34201,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194 /* OmittedExpression */) { + if (patternElement.kind !== 198 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32363,7 +34218,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, @@ -32431,9 +34286,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 === 172 /* ObjectBindingPattern */ || contextualType.pattern.kind === 176 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32441,18 +34298,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 === 257 /* PropertyAssignment */ || + memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253 /* PropertyAssignment */) { + if (memberDecl.kind === 257 /* 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 === 258 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -32460,8 +34317,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 === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -32469,8 +34326,7 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & 2588672 /* ObjectType */ && contextualType.isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.name); @@ -32490,13 +34346,30 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 259 /* 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)) { @@ -32526,18 +34399,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 : 16777216 /* FreshLiteral */; - result.flags |= 8388608 /* ObjectLiteral */ | 67108864 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 234881024 /* PropagatingFlags */); - if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + 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 |= 128 /* ObjectLiteral */; + if (patternWithComputedProperties) { + result.objectFlags |= 512 /* 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); @@ -32557,13 +34445,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 252 /* JsxExpression */: checkJsxExpression(child); break; - case 242 /* JsxElement */: + case 246 /* JsxElement */: checkJsxElement(child); break; - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32582,7 +34470,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 177 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32600,7 +34488,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; } @@ -32693,7 +34581,7 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node, valueType) { - ts.Debug.assert(!(valueType.flags & 524288 /* Union */)); + ts.Debug.assert(!(valueType.flags & 65536 /* Union */)); if (isTypeAny(valueType)) { // Short-circuit if the class tag is using an element type 'any' return anyType; @@ -32751,7 +34639,7 @@ var ts; if (!elemType) { elemType = checkExpression(node.tagName); } - if (elemType.flags & 524288 /* Union */) { + if (elemType.flags & 65536 /* Union */) { var types = elemType.types; return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); @@ -32825,7 +34713,7 @@ var ts; // Props is of type 'any' or unknown return attributesType; } - else if (attributesType.flags & 524288 /* Union */) { + else if (attributesType.flags & 65536 /* Union */) { // Props cannot be a union type error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; @@ -32914,13 +34802,19 @@ 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) { - getSymbolLinks(reactSym).referenced = true; + // Mark local symbol as referenced here because it might not have been marked + // if jsx emit was not react as there wont be error being emitted + reactSym.isReferenced = true; + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 8388608 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + markAliasSymbolAsReferenced(reactSym); + } } var targetAttributesType = getJsxElementAttributesType(node); var nameTable = ts.createMap(); @@ -32929,11 +34823,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 === 250 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -32963,7 +34857,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; @@ -32982,7 +34876,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 === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -32993,7 +34887,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); @@ -33047,7 +34941,7 @@ var ts; type = getConstraintOfTypeParameter(type); } // TODO: why is the first part of this check here? - if (!(getTargetType(type).flags & (32768 /* Class */ | 65536 /* Interface */) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & 3 /* ClassOrInterface */ && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -33073,6 +34967,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) { @@ -33090,47 +35011,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 !== 177 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && - !(prop.flags & 8192 /* Method */ && propType.flags & 524288 /* Union */)) { + !(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 & 524288 /* 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 === 177 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -33147,7 +35053,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer.kind === 224 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -33169,14 +35075,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 === 212 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -33190,10 +35096,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 === 180 /* 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); @@ -33203,101 +35110,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. @@ -33334,10 +35158,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 181 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 144 /* Decorator */) { + else if (node.kind !== 145 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33367,13 +35191,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_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_9; index = cutoffIndex; } } @@ -33381,7 +35205,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_9; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -33403,7 +35227,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 === 196 /* SpreadElement */) { return i; } } @@ -33416,13 +35240,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 === 181 /* 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 === 194 /* 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; @@ -33439,7 +35263,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); @@ -33448,7 +35272,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 === 180 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33479,7 +35303,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -33532,7 +35356,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 !== 198 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -33589,7 +35413,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 !== 180 /* 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. @@ -33606,7 +35430,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 !== 198 /* 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); @@ -33628,12 +35452,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 === 179 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 173 /* PropertyAccessExpression */) { + if (callee.kind === 177 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 174 /* ElementAccessExpression */) { + else if (callee.kind === 178 /* ElementAccessExpression */) { return callee.expression; } } @@ -33649,16 +35473,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 181 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 190 /* TemplateExpression */) { + if (template.kind === 194 /* 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. @@ -33683,19 +35507,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 226 /* ClassDeclaration */: + case 197 /* 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. @@ -33705,7 +35529,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; @@ -33729,25 +35553,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 226 /* 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 @@ -33774,21 +35598,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 226 /* 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 @@ -33799,7 +35623,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; @@ -33825,21 +35649,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 === 226 /* 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); @@ -33871,10 +35695,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 === 181 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -33886,8 +35710,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 === 181 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -33896,11 +35720,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 === 181 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -33909,8 +35733,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 === 181 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 145 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -33981,7 +35805,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 === 179 /* 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 @@ -34020,7 +35844,7 @@ var ts; else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { var typeArguments_2 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNodeNoAlias), /*reportErrors*/ true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -34047,7 +35871,7 @@ var ts; var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNodeNoAlias)); + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); } return candidate; } @@ -34079,7 +35903,7 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNodeNoAlias); + typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { @@ -34195,7 +36019,7 @@ var ts; if (!numCallSignatures && !numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have // no common signatures. - if (funcType.flags & 524288 /* Union */) { + if (funcType.flags & 65536 /* Union */) { return false; } return isTypeAssignableTo(funcType, globalFunctionType); @@ -34329,16 +36153,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 197 /* 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; } } @@ -34368,13 +36192,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175 /* CallExpression */: + case 179 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144 /* Decorator */: + case 145 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34423,12 +36247,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 176 /* NewExpression */) { + if (node.kind === 180 /* 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 @@ -34448,14 +36272,37 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && - ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && - // Make sure require is not a local function - !resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (ts.isInJavaScriptFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); } + function isCommonJsRequire(node) { + if (!ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + return false; + } + // Make sure require is not a local function + var resolvedRequire = resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!resolvedRequire) { + // project does not contain symbol named 'require' - assume commonjs require + return true; + } + // project includes symbol named 'require' - make sure that it it ambient and local non-alias + if (resolvedRequire.flags & 8388608 /* Alias */) { + return false; + } + var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ + ? 225 /* FunctionDeclaration */ + : resolvedRequire.flags & 3 /* Variable */ + ? 223 /* VariableDeclaration */ + : 0 /* Unknown */; + if (targetDeclarationKind !== 0 /* Unknown */) { + var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + // function/variable declaration should be ambient + return ts.isInAmbientContext(decl); + } + return false; + } function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } @@ -34544,8 +36391,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 === 172 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 173 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34603,7 +36450,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; @@ -34615,7 +36462,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200 /* Block */) { + if (func.body.kind !== 204 /* 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 @@ -34705,7 +36552,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -34738,7 +36585,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { + func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -34767,7 +36614,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 !== 204 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -34800,10 +36647,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 === 184 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -34844,14 +36691,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) { @@ -34867,7 +36714,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200 /* Block */) { + if (node.body.kind === 204 /* Block */) { checkSourceElement(node.body); } else { @@ -34914,11 +36761,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 === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* 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, @@ -34930,50 +36777,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 === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* 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 === 237 /* 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 !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* 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) { @@ -34991,7 +36813,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)) { @@ -35027,7 +36849,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; } @@ -35041,7 +36863,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; } @@ -35051,7 +36873,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 1572864 /* UnionOrIntersection */) { + if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -35069,7 +36891,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -35079,7 +36901,7 @@ var ts; } return true; } - if (type.flags & 1048576 /* Intersection */) { + if (type.flags & 131072 /* Intersection */) { var types = type.types; for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { var t = types_17[_a]; @@ -35091,7 +36913,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (2588672 /* ObjectType */ | 2097152 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + return getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -35125,36 +36947,36 @@ var ts; if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */ | 340 /* NumberLike */ | 512 /* ESSymbol */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 /* ObjectType */ | 16384 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } 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 === 257 /* PropertyAssignment */ || property.kind === 258 /* 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 === 258 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -35163,7 +36985,12 @@ 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 if (property.kind === 259 /* SpreadAssignment */) { + if (property.expression.kind !== 70 /* Identifier */) { + error(property.expression, ts.Diagnostics.An_object_rest_element_must_be_an_identifier); } } else { @@ -35184,8 +37011,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 !== 198 /* OmittedExpression */) { + if (element.kind !== 196 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -35209,11 +37036,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 === 192 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -35226,7 +37053,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -35242,21 +37069,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 192 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 176 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171 /* ArrayLiteralExpression */) { + if (target.kind === 175 /* 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; @@ -35275,35 +37102,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 177 /* TaggedTemplateExpression */: - case 190 /* TemplateExpression */: + case 181 /* TaggedTemplateExpression */: + case 194 /* 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 184 /* FunctionExpression */: + case 197 /* ClassExpression */: + case 185 /* ArrowFunction */: + case 175 /* ArrayLiteralExpression */: + case 176 /* ObjectLiteralExpression */: + case 187 /* TypeOfExpression */: + case 201 /* NonNullExpression */: + case 247 /* JsxSelfClosingElement */: + case 246 /* JsxElement */: return true; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -35315,9 +37142,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 188 /* VoidExpression */: // Explicit opt-out + case 182 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 200 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35337,7 +37164,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 === 176 /* ObjectLiteralExpression */ || left.kind === 175 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -35520,9 +37347,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); } @@ -35550,7 +37375,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)) { @@ -35638,8 +37463,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 === 182 /* TypeAssertionExpression */ || node.kind === 200 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35671,7 +37496,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); @@ -35682,7 +37507,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); @@ -35712,7 +37537,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 { @@ -35724,9 +37549,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 === 177 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 178 /* 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); } @@ -35748,66 +37573,66 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return checkCallExpression(node); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return checkClassExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: return checkAssertion(node); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: return checkNonNullAssertion(node); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return checkDeleteExpression(node); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return checkVoidExpression(node); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return checkAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 192 /* SpreadElementExpression */: - return checkSpreadElementExpression(node, contextualMapper); - case 194 /* OmittedExpression */: + case 196 /* SpreadElement */: + return checkSpreadExpression(node, contextualMapper); + case 198 /* OmittedExpression */: return undefinedWideningType; - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return checkYieldExpression(node); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return checkJsxExpression(node); - case 242 /* JsxElement */: + case 246 /* JsxElement */: return checkJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -35835,7 +37660,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); } } @@ -35846,7 +37671,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); } } @@ -35860,9 +37685,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 === 225 /* FunctionDeclaration */ || + node.kind === 184 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -35905,9 +37730,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; } @@ -35920,16 +37745,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 185 /* ArrowFunction */: + case 153 /* CallSignature */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 158 /* FunctionType */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -35939,15 +37764,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 === 173 /* ArrayBindingPattern */ || + name_23.kind === 172 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } @@ -35955,12 +37780,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 === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || + node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -35972,10 +37797,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; } @@ -36018,7 +37843,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)) { @@ -36032,13 +37857,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; } @@ -36064,7 +37889,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 */: @@ -36086,7 +37911,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223 /* InterfaceDeclaration */) { + if (node.kind === 227 /* 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 @@ -36106,7 +37931,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; } @@ -36114,7 +37939,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -36182,12 +38007,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 !== 184 /* FunctionExpression */ && n.kind !== 225 /* 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; } @@ -36217,7 +38042,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 === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -36241,7 +38066,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); @@ -36251,13 +38076,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 */)) { @@ -36273,11 +38098,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 !== 176 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36307,7 +38132,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -36360,6 +38185,17 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } + function checkMappedType(node) { + checkSourceElement(node.typeParameter); + checkSourceElement(node.type); + var type = getTypeFromMappedTypeNode(node); + var constraintType = getConstraintTypeFromMappedType(type); + var keyType = constraintType.flags & 16384 /* TypeParameter */ ? getApparentTypeOfTypeParameter(constraintType) : constraintType; + checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); } @@ -36367,9 +38203,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 !== 227 /* InterfaceDeclaration */ && + n.parent.kind !== 226 /* ClassDeclaration */ && + n.parent.kind !== 197 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36457,7 +38293,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 @@ -36496,7 +38332,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 === 227 /* 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 @@ -36507,7 +38343,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 === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36629,16 +38465,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -36679,7 +38515,7 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (promise.flags & 131072 /* Reference */) { + if (getObjectFlags(promise) & 4 /* Reference */) { if (promise.target === tryGetGlobalPromiseType() || promise.target === getGlobalPromiseLikeType()) { return promise.typeArguments[0]; @@ -36723,7 +38559,7 @@ var ts; function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); function checkAwaitedTypeWorker(type) { - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var types = []; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -36802,56 +38638,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 @@ -36876,39 +38675,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) { @@ -36921,22 +38737,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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]); @@ -36944,42 +38760,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 */ @@ -36998,21 +38791,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 226 /* 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; } } @@ -37034,7 +38833,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); @@ -37094,43 +38893,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 261 /* SourceFile */: + case 230 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 200 /* Block */: - case 228 /* CaseBlock */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 204 /* Block */: + case 232 /* CaseBlock */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* 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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* 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; } @@ -37139,43 +38938,57 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_1 = function (key) { + if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 143 /* Parameter */) { - var parameter = local.valueDeclaration; + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { + var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { + !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return error(d.name || d, ts.Diagnostics._0_is_declared_but_never_used, local.name); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } }; for (var key in node.locals) { - _loop_1(key); + _loop_3(key); } } } - function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 70 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; + function errorUnusedLocal(node, name) { + if (isIdentifierThatStartsWithUnderScore(node)) { + var declaration = ts.getRootDeclaration(node.parent); + if (declaration.kind === 223 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 212 /* ForInStatement */ || + declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + return; + } + } + error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + } + function parameterNameStartsWithUnderscore(parameterName) { + return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); + } + function isIdentifierThatStartsWithUnderScore(node) { + return node.kind === 70 /* Identifier */ && node.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { 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 */) { @@ -37223,7 +39036,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 200 /* Block */) { + if (node.kind === 204 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -37246,12 +39059,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; } @@ -37260,7 +39073,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; } @@ -37317,12 +39130,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 230 /* 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 === 261 /* 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)); } @@ -37332,12 +39145,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 230 /* 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 === 261 /* 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)); } @@ -37372,7 +39185,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 === 223 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37382,24 +39195,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, 224 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 205 /* 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 === 204 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 231 /* ModuleBlock */ || + container.kind === 230 /* ModuleDeclaration */ || + container.kind === 261 /* 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); } } } @@ -37407,7 +39220,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); @@ -37418,7 +39231,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 173 /* PropertyAccessExpression */) { + if (n.kind === 177 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -37437,7 +39250,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) { @@ -37451,7 +39264,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; @@ -37478,24 +39291,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 === 174 /* 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_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + markPropertyAsReferenced(property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -37503,14 +39317,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 !== 212 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37521,7 +39335,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 !== 212 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37541,10 +39355,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 === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37554,8 +39368,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 === 223 /* VariableDeclaration */) || + (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37585,7 +39399,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 === 176 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37606,7 +39420,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202 /* EmptyStatement */) { + if (node.thenStatement.kind === 206 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37626,12 +39440,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 === 224 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 224 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37654,14 +39468,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 === 224 /* 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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* 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. @@ -37669,8 +39483,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 @@ -37693,7 +39506,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 === 224 /* 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); @@ -37707,7 +39520,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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* 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 */)) { @@ -37715,13 +39528,13 @@ 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); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 /* ObjectType */ | 16384 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -37803,7 +39616,7 @@ var ts; if (!typeAsIterable.iterableElementType) { // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), // then just grab its type argument. - if ((type.flags & 131072 /* Reference */) && type.target === getGlobalIterableType()) { + if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableType()) { typeAsIterable.iterableElementType = type.typeArguments[0]; } else { @@ -37844,7 +39657,7 @@ var ts; if (!typeAsIterator.iteratorElementType) { // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), // then just grab its type argument. - if ((type.flags & 131072 /* Reference */) && type.target === getGlobalIteratorType()) { + if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIteratorType()) { typeAsIterator.iteratorElementType = type.typeArguments[0]; } else { @@ -37881,7 +39694,7 @@ var ts; } // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), // then just grab its type argument. - if ((type.flags & 131072 /* Reference */) && type.target === getGlobalIterableIteratorType()) { + if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableIteratorType()) { return type.typeArguments[0]; } return getElementTypeOfIterable(type, /*errorNode*/ undefined) || @@ -37909,8 +39722,12 @@ var ts; // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 524288 /* Union */) { - arrayType = getUnionType(ts.filter(arrayOrStringType.types, function (t) { return !(t.flags & 34 /* StringLike */); }), /*subtypeReduction*/ true); + if (arrayOrStringType.flags & 65536 /* Union */) { + var arrayTypes = arrayOrStringType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34 /* StringLike */); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); + } } else if (arrayOrStringType.flags & 34 /* StringLike */) { arrayType = neverType; @@ -37957,7 +39774,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; @@ -37984,12 +39801,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); } @@ -38010,7 +39827,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); } @@ -38019,7 +39836,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); } } @@ -38037,9 +39854,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 === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -38051,15 +39869,21 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 253 /* 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); @@ -38076,7 +39900,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 219 /* 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; @@ -38106,22 +39930,20 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 70 /* Identifier */) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { + if (catchClause.variableDeclaration.type) { grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); } else if (catchClause.variableDeclaration.initializer) { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2 /* BlockScopedVariable */) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + var blockLocals = catchClause.block.locals; + if (blockLocals) { + for (var caughtName in catchClause.locals) { + var blockLocal = blockLocals[caughtName]; + if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); + } } } } @@ -38143,7 +39965,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 32768 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { + if (getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -38162,7 +39984,7 @@ var ts; if (stringIndexType && numberIndexType) { errorNode = declaredNumberIndexer || declaredStringIndexer; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (type.flags & 65536 /* Interface */)) { + if (!errorNode && (getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } @@ -38181,13 +40003,13 @@ 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) { errorNode = indexDeclaration; } - else if (containingType.flags & 65536 /* Interface */) { + else if (getObjectFlags(containingType) & 2 /* Interface */) { // for interfaces property and indexer might be inherited from different bases // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together @@ -38239,7 +40061,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 === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38302,7 +40124,9 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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)) { + if (baseType_1.symbol.valueDeclaration && + !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && + baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -38331,8 +40155,8 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = (t.flags & 131072 /* Reference */) ? t.target : t; - if (declaredType.flags & (32768 /* Class */ | 65536 /* Interface */)) { + var declaredType = getObjectFlags(t) & 4 /* Reference */ ? t.target : t; + if (getObjectFlags(declaredType) & 3 /* ClassOrInterface */) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -38354,7 +40178,7 @@ var ts; if (declaration && ts.getModifierFlags(declaration) & 8 /* Private */) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { - error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); } } } @@ -38403,7 +40227,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 === 197 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38451,7 +40275,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) { @@ -38492,8 +40316,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 }; @@ -38523,7 +40347,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, 227 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38554,6 +40378,7 @@ var ts; // Grammar checking checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } function computeEnumMemberValues(node) { @@ -38570,7 +40395,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); } @@ -38629,7 +40454,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -38640,7 +40465,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38665,11 +40490,11 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: + case 177 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -38682,7 +40507,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174 /* ElementAccessExpression */) { + if (e.kind === 178 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38700,7 +40525,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 173 /* PropertyAccessExpression */) { + else if (current.kind === 177 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -38772,7 +40597,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 !== 229 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -38795,8 +40620,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 === 226 /* ClassDeclaration */ || + (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -38860,7 +40685,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, 226 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -38911,26 +40736,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201 /* VariableStatement */: + case 205 /* 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 240 /* ExportAssignment */: + case 241 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230 /* ImportEqualsDeclaration */: - case 231 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 235 /* 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 174 /* BindingElement */: + case 223 /* 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); @@ -38938,12 +40763,12 @@ var ts; break; } // fallthrough - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 221 /* FunctionDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 225 /* FunctionDeclaration */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 228 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -38966,12 +40791,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 177 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -38984,9 +40809,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 === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 241 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -39019,7 +40844,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 === 243 /* 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)); @@ -39047,7 +40872,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -39104,8 +40929,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 === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -39119,7 +40944,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 === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -39145,8 +40970,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 === 261 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -39221,7 +41046,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || + return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -39234,118 +41059,123 @@ 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 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 225 /* 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 170 /* MappedType */: + return checkMappedType(node); + case 225 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 204 /* Block */: + case 231 /* ModuleBlock */: return checkBlock(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return checkVariableStatement(node); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return checkExpressionStatement(node); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return checkIfStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return checkDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return checkWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return checkForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return checkForInStatement(node); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return checkForOfStatement(node); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 214 /* ContinueStatement */: + case 215 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return checkReturnStatement(node); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return checkWithStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return checkSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return checkLabeledStatement(node); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return checkThrowStatement(node); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return checkTryStatement(node); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 170 /* BindingElement */: + case 174 /* BindingElement */: return checkBindingElement(node); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return checkClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return checkImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return checkExportDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return checkExportAssignment(node); - case 202 /* EmptyStatement */: + case 206 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 218 /* DebuggerStatement */: + case 222 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 240 /* MissingDeclaration */: + case 244 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39367,17 +41197,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 184 /* FunctionExpression */: + case 185 /* 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 197 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39439,9 +41269,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(); } @@ -39458,7 +41308,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 === 217 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39481,25 +41331,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 193 /* ClassExpression */: + case 197 /* 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 226 /* ClassDeclaration */: + case 227 /* 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. @@ -39508,7 +41358,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39557,28 +41407,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 229 /* 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 === 272 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 177 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 199 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39595,13 +41445,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 === 234 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39613,7 +41463,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 === 177 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39625,13 +41475,13 @@ var ts; default: } } - if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 240 /* 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 !== 177 /* 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, 234 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -39641,7 +41491,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 === 199 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39665,14 +41515,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 173 /* PropertyAccessExpression */) { + else if (entityName.kind === 177 /* 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); @@ -39681,20 +41531,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 === 272 /* 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 === 250 /* 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 === 261 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -39712,8 +41562,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 === 174 /* BindingElement */ && + node.parent.parent.kind === 172 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -39724,8 +41574,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 177 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -39739,12 +41589,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; @@ -39752,7 +41602,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 === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -39762,7 +41612,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -39779,7 +41629,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 === 258 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -39841,28 +41691,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 === 176 /* ObjectLiteralExpression */ || expr.kind === 175 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 209 /* ForOfStatement */) { + if (expr.parent.kind === 213 /* 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 === 192 /* 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 === 257 /* 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 === 175 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -39912,9 +41762,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); } @@ -39922,6 +41772,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) { @@ -39994,7 +41848,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 === 261 /* 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. @@ -40051,7 +41905,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 === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -40097,16 +41951,16 @@ var ts; return true; } switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportClause */: + case 237 /* NamespaceImport */: + case 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -40116,7 +41970,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 !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -40182,7 +42036,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255 /* EnumMember */) { + if (node.kind === 260 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -40195,7 +42049,7 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 2588672 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. @@ -40283,9 +42137,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_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -40305,7 +42159,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 16777216 /* FreshLiteral */); + return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 1048576 /* FreshLiteral */); } return false; } @@ -40359,7 +42213,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) { @@ -40370,7 +42225,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 === 177 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40396,6 +42251,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; @@ -40409,15 +42268,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_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -40437,7 +42296,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -40470,7 +42329,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) { @@ -40549,9 +42408,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) { @@ -40587,7 +42450,7 @@ var ts; // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(2097152 /* Anonymous */); + var thenableType = createObjectType(16 /* Anonymous */); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; @@ -40600,14 +42463,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); @@ -40624,17 +42487,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 !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -40660,7 +42523,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 === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -40683,10 +42546,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 === 231 /* ModuleBlock */ || node.parent.kind === 261 /* 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 */) { @@ -40695,11 +42558,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); } @@ -40719,10 +42582,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 === 226 /* 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 */; @@ -40734,13 +42597,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 === 226 /* 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 === 231 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -40750,14 +42613,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 !== 226 /* 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 === 226 /* 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 */) { @@ -40776,7 +42639,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 */; @@ -40784,7 +42647,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"); } @@ -40799,13 +42662,13 @@ var ts; } return; } - else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* 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 */) { @@ -40825,37 +42688,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 230 /* ModuleDeclaration */: + case 235 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 241 /* ExportDeclaration */: + case 240 /* ExportAssignment */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 144 /* Parameter */: return false; default: - if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { return false; } switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 223 /* InterfaceDeclaration */: - case 201 /* VariableStatement */: - case 224 /* TypeAliasDeclaration */: + case 227 /* InterfaceDeclaration */: + case 205 /* VariableStatement */: + case 228 /* TypeAliasDeclaration */: return true; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -40868,10 +42731,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -40934,7 +42797,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 185 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -40969,7 +42832,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) { @@ -40997,7 +42860,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 === 198 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -41070,19 +42933,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 === 192 /* 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 === 225 /* FunctionDeclaration */ || + node.kind === 184 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -41107,12 +42970,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 === 259 /* 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 === 258 /* 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); @@ -41121,7 +42987,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)); } } @@ -41135,27 +43001,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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* 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; } @@ -41165,18 +43031,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); } } } @@ -41185,19 +43051,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 === 251 /* 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 === 252 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -41206,7 +43072,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -41221,20 +43087,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 212 /* 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 === 212 /* 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 === 212 /* 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); @@ -41258,11 +43124,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); } @@ -41285,10 +43151,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); } } @@ -41303,7 +43169,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (node.parent.kind === 176 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -41324,10 +43190,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 === 227 /* 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); } } @@ -41338,11 +43204,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215 /* LabeledStatement */: + case 219 /* 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 === 214 /* 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); @@ -41350,8 +43216,8 @@ var ts; return false; } break; - case 214 /* SwitchStatement */: - if (node.kind === 211 /* BreakStatement */ && !node.label) { + case 218 /* SwitchStatement */: + if (node.kind === 215 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41366,13 +43232,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 /* BreakStatement */ + var message = node.kind === 215 /* 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 === 215 /* 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); @@ -41382,24 +43248,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 === 173 /* ArrayBindingPattern */ || node.name.kind === 172 /* 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 === 190 /* 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 !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41464,15 +43330,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 208 /* IfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 217 /* WithStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: return false; - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41527,7 +43393,7 @@ var ts; return true; } } - else if (node.parent.kind === 223 /* InterfaceDeclaration */) { + else if (node.parent.kind === 227 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41535,7 +43401,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; } @@ -41560,13 +43426,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 === 227 /* InterfaceDeclaration */ || + node.kind === 228 /* TypeAliasDeclaration */ || + node.kind === 235 /* ImportDeclaration */ || + node.kind === 234 /* ImportEqualsDeclaration */ || + node.kind === 241 /* ExportDeclaration */ || + node.kind === 240 /* ExportAssignment */ || + node.kind === 233 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41575,7 +43441,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 === 205 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41601,7 +43467,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 === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41661,49 +43527,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[182 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196 /* AsExpression */] = [ + _a[200 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197 /* NonNullExpression */] = [ + _a[201 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225 /* EnumDeclaration */] = [ + _a[229 /* 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[230 /* 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[231 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[230 /* ImportEqualsDeclaration */] = [ + _a[234 /* 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[245 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255 /* EnumMember */] = [ + _a[260 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -41726,47 +43592,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 <= 171 /* 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 203 /* SemicolonClassElement */: + case 206 /* EmptyStatement */: + case 198 /* OmittedExpression */: + case 222 /* DebuggerStatement */: + case 292 /* 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); @@ -41775,12 +43641,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); @@ -41788,7 +43654,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); @@ -41796,45 +43662,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 170 /* BindingElement */: + case 174 /* 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 175 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175 /* CallExpression */: + case 179 /* 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 180 /* 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 181 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -41842,119 +43708,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181 /* ArrowFunction */: + case 185 /* 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 183 /* ParenthesizedExpression */: + case 186 /* DeleteExpression */: + case 187 /* TypeOfExpression */: + case 188 /* VoidExpression */: + case 189 /* AwaitExpression */: + case 195 /* YieldExpression */: + case 196 /* SpreadElement */: + case 201 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193 /* ClassExpression */: + case 197 /* 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 199 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 200 /* Block */: + case 204 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 204 /* IfStatement */: + case 208 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205 /* DoStatement */: + case 209 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206 /* WhileStatement */: - case 213 /* WithStatement */: + case 210 /* WhileStatement */: + case 217 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForStatement */: + case 211 /* 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 212 /* ForInStatement */: + case 213 /* 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 216 /* ReturnStatement */: + case 220 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217 /* TryStatement */: + case 221 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41963,7 +43829,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41971,94 +43837,97 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 231 /* ImportDeclaration */: + case 235 /* 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 236 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236 /* ExportAssignment */: + case 240 /* 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 241 /* 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 246 /* 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 247 /* JsxSelfClosingElement */: + case 248 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: result = reduceNode(node.tagName, f, result); break; - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: result = reduceNode(node.expression, f, result); break; - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: result = reduceNode(node.expression, f, result); break; // Clauses - case 249 /* CaseClause */: + case 253 /* CaseClause */: result = reduceNode(node.expression, f, result); // fall-through - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: result = ts.reduceLeft(node.statements, f, result); break; - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: result = ts.reduceLeft(node.types, f, result); break; - case 252 /* CatchClause */: + case 256 /* CatchClause */: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; // Property assignments - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; + case 259 /* SpreadAssignment */: + result = reduceNode(node.expression, f, result); + break; // Top-level nodes - case 256 /* SourceFile */: + case 261 /* SourceFile */: result = ts.reduceLeft(node.statements, f, result); break; - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, f, result); break; default: @@ -42083,6 +43952,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -42131,6 +44001,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) { @@ -42169,192 +44040,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 <= 171 /* LiteralType */)) { return node; } switch (node.kind) { - case 199 /* SemicolonClassElement */: - case 202 /* EmptyStatement */: - case 194 /* OmittedExpression */: - case 218 /* DebuggerStatement */: + case 203 /* SemicolonClassElement */: + case 206 /* EmptyStatement */: + case 198 /* OmittedExpression */: + case 222 /* 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 172 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169 /* ArrayBindingPattern */: + case 173 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170 /* BindingElement */: + case 174 /* 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 175 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175 /* CallExpression */: + case 179 /* 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 180 /* 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 181 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180 /* FunctionExpression */: + case 184 /* 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 185 /* 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 186 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189 /* ConditionalExpression */: + case 193 /* 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 194 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* SpreadElementExpression */: + case 196 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ClassExpression */: + case 197 /* 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 199 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 200 /* Block */: + case 204 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* IfStatement */: + case 208 /* 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 209 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 207 /* ForStatement */: + case 211 /* 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 212 /* 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 213 /* 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 214 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* TryStatement */: + case 221 /* 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 223 /* 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 224 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 221 /* FunctionDeclaration */: + case 225 /* 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 226 /* 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 232 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 231 /* ImportDeclaration */: + case 235 /* 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 236 /* 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 237 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 234 /* NamedImports */: + case 238 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 235 /* ImportSpecifier */: + case 239 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 236 /* ExportAssignment */: + case 240 /* 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 241 /* 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 242 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 242 /* JsxElement */: + case 246 /* 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 247 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 249 /* CaseClause */: + case 253 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 259 /* SpreadAssignment */: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 256 /* SourceFile */: + case 261 /* 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 293 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -42436,7 +44309,7 @@ var ts; return 0 /* None */; } else if (node.transformFlags & 536870912 /* HasComputedFlags */) { - return node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); + return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind); } else { var subtreeFlags = aggregateTransformFlagsForSubtree(node); @@ -42462,75 +44335,17 @@ var ts; function aggregateTransformFlagsForChildNode(transformFlags, child) { return transformFlags | aggregateTransformFlagsForNode(child); } - /** - * Gets the transform flags to exclude when unioning the transform flags of a subtree. - * - * NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`. - * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather - * than calling this function. - */ - function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* 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 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: - case 133 /* StringKeyword */: - case 121 /* BooleanKeyword */: - case 134 /* 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 */: - return -3 /* TypeExcludes */; - case 172 /* ObjectLiteralExpression */: - return 539110741 /* ObjectLiteralExcludes */; - default: - return 536874325 /* NodeExcludes */; - } - } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function () { }; + : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function () { }; + : ts.noop; Debug.assertNode = Debug.shouldAssert(1 /* Normal */) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function () { }; + : ts.noop; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -42561,7 +44376,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)) { @@ -42592,7 +44407,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); } @@ -42612,6 +44427,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; /** @@ -42621,9 +44439,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); @@ -42638,6 +44456,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; /** @@ -42647,10 +44468,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) { @@ -42682,6 +44503,9 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; /** @@ -42689,36 +44513,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); } @@ -42750,17 +44578,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 176 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171 /* ArrayLiteralExpression */) { + else if (target.kind === 175 /* 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) { @@ -42771,30 +44599,96 @@ 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 === 257 /* PropertyAssignment */ || p.kind === 258 /* ShorthandPropertyAssignment */) { + if (!transformRest || + p.transformFlags & 8388608 /* ContainsSpreadExpression */ || + (p.kind === 257 /* PropertyAssignment */ && p.initializer.transformFlags & 8388608 /* ContainsSpreadExpression */)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 258 /* 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 === 259 /* SpreadAssignment */ && + 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 === 198 /* 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 !== 198 /* 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 !== 196 /* SpreadElement */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -42803,10 +44697,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; } @@ -42815,9 +44729,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 @@ -42825,29 +44741,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 === 173 /* 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) { @@ -42938,15 +44923,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(177 /* PropertyAccessExpression */); + context.enableSubstitution(178 /* 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. @@ -43007,7 +44992,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 261 /* SourceFile */) { return visitSourceFile(node); } else if (node.transformFlags & 1 /* TypeScript */) { @@ -43035,13 +45020,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return visitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -43061,11 +45046,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 === 241 /* ExportDeclaration */ || + node.kind === 235 /* ImportDeclaration */ || + node.kind === 236 /* ImportClause */ || + (node.kind === 234 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 245 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -43095,25 +45080,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 203 /* 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. * @@ -43136,45 +45130,48 @@ 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 /* MappedType */: + case 171 /* 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 228 /* 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 227 /* 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 226 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43185,7 +45182,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43196,35 +45193,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 195 /* ExpressionWithTypeArguments */: + case 199 /* 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 225 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 185 /* 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: @@ -43234,33 +45231,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return visitNewExpression(node); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -43275,15 +45272,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 256 /* SourceFile */: - case 228 /* CaseBlock */: - case 227 /* ModuleBlock */: - case 200 /* Block */: + case 261 /* SourceFile */: + case 232 /* CaseBlock */: + case 231 /* ModuleBlock */: + case 204 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222 /* ClassDeclaration */: - case 221 /* FunctionDeclaration */: + case 226 /* ClassDeclaration */: + case 225 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -43294,13 +45291,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(); @@ -43313,10 +45314,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; } @@ -43360,7 +45361,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 @@ -43369,38 +45369,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. @@ -43409,26 +45393,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. // @@ -43463,20 +45475,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 @@ -43505,59 +45517,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. @@ -43620,7 +45604,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. @@ -43740,7 +45724,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -43813,7 +45797,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; } @@ -43948,12 +45932,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; @@ -44105,11 +46089,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; } @@ -44118,8 +46102,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)); } @@ -44129,33 +46113,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. @@ -44177,7 +46147,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); @@ -44202,13 +46172,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))); } } } @@ -44216,16 +46186,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))); } } } @@ -44238,10 +46208,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. @@ -44251,7 +46221,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. @@ -44262,11 +46232,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 === 226 /* ClassDeclaration */ + || kind === 197 /* ClassExpression */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -44275,15 +46245,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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -44296,10 +46266,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 { @@ -44375,20 +46345,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 171 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -44402,16 +46372,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; @@ -44440,10 +46410,13 @@ var ts; } } // Fallthrough - case 159 /* TypeQuery */: - case 160 /* TypeLiteral */: + case 160 /* TypeQuery */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* MappedType */: + case 161 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44500,15 +46473,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); } } @@ -44641,7 +46614,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); @@ -44675,14 +46648,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; } /** @@ -44699,13 +46672,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; } /** @@ -44723,7 +46696,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); @@ -44747,7 +46720,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); @@ -44760,7 +46733,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); @@ -44820,7 +46793,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, @@ -44857,7 +46830,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), @@ -44923,21 +46896,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. * @@ -44956,9 +46914,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 */; @@ -44969,7 +46925,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"; // ... @@ -44978,16 +46945,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; } /** @@ -45049,9 +47016,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 @@ -45077,55 +47050,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 === 229 /* 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. @@ -45147,9 +47129,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 */; @@ -45160,13 +47140,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); } @@ -45177,13 +47159,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; } /** @@ -45203,7 +47188,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227 /* ModuleBlock */) { + if (body.kind === 231 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -45249,13 +47234,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 !== 231 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -45296,7 +47281,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 233 /* NamespaceImport */) { + if (node.kind === 237 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -45403,9 +47388,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 { @@ -45454,38 +47439,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. @@ -45503,67 +47470,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() { @@ -45588,20 +47513,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(258 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(226 /* ModuleDeclaration */); + context.enableEmitNotification(230 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 229 /* 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. */ @@ -45619,9 +47545,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); @@ -45635,16 +47560,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; @@ -45653,9 +47578,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -45689,13 +47614,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 !== 261 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45774,11 +47699,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242 /* JsxElement */: + case 246 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -45789,11 +47714,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return visitJsxExpression(node); - case 242 /* JsxElement */: + case 246 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -45830,7 +47755,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); } @@ -45852,7 +47777,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 === 252 /* JsxExpression */) { return visitJsxExpression(node); } else { @@ -45934,16 +47859,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242 /* JsxElement */) { + if (node.kind === 246 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_31 = node.tagName; - if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { - return ts.createLiteral(name_31.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_31); + return ts.createExpressionFromEntityName(name_34); } } } @@ -46228,6 +48153,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 176 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 192 /* BinaryExpression */: + return visitBinaryExpression(node); + case 223 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 213 /* ForOfStatement */: + return visitForOfStatement(node); + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: + return node; + case 225 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 184 /* FunctionExpression */: + return visitFunctionExpression(node); + case 185 /* 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 === 259 /* 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 === 257 /* 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 !== 176 /* 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 === 172 /* ObjectBindingPattern */ && + !!(declaration.name.transformFlags & 8388608 /* ContainsSpreadExpression */); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 176 /* 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 === 172 /* 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; @@ -46272,10 +48423,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; @@ -46285,19 +48436,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 185 /* AwaitExpression */: + case 189 /* 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 225 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -46418,9 +48569,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 === 185 /* 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 @@ -46470,12 +48622,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; @@ -46485,24 +48639,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(179 /* CallExpression */); + context.enableSubstitution(177 /* PropertyAccessExpression */); + context.enableSubstitution(178 /* 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(226 /* 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 177 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -46546,11 +48700,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 === 226 /* ClassDeclaration */ + || kind === 150 /* Constructor */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Hook for node emit. @@ -46616,10 +48770,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 { @@ -46628,7 +48782,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -46742,6 +48896,7 @@ var ts; var enclosingFunction; var enclosingNonArrowFunction; var enclosingNonAsyncFunctionBody; + var isInConstructorWithCapturedSuper; /** * Used to track if we are emitting body of the converted loop */ @@ -46779,12 +48934,15 @@ var ts; var savedCurrentParent = currentParent; var savedCurrentNode = currentNode; var savedConvertedLoopState = convertedLoopState; + var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy + // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body + isInConstructorWithCapturedSuper = false; convertedLoopState = undefined; } onBeforeVisitNode(node); var visited = f(node); + isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; convertedLoopState = savedConvertedLoopState; enclosingFunction = savedEnclosingFunction; enclosingNonArrowFunction = savedEnclosingNonArrowFunction; @@ -46796,16 +48954,28 @@ var ts; currentNode = savedCurrentNode; return visited; } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + } + function isReturnVoidStatementInConstructorWithCapturedSuper(node) { + return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + } function shouldCheckNode(node) { - return (node.transformFlags & 256 /* ES2015 */) !== 0 || - node.kind === 215 /* LabeledStatement */ || + return (node.transformFlags & 1024 /* ES2015 */) !== 0 || + node.kind === 219 /* LabeledStatement */ || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { - if (shouldCheckNode(node)) { + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 /* ContainsES2015 */) { + 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 return ts.visitEachChild(node, visitor, context); } else { @@ -46824,14 +48994,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: + node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitVariableStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return visitSwitchStatement(node); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: return visitBreakOrContinueStatement(node); case 98 /* ThisKeyword */: return visitThisKeyword(node); @@ -46843,75 +49014,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 226 /* ClassDeclaration */: return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return visitClassExpression(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return visitParameter(node); - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return visitArrowFunction(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return visitLabeledStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return visitWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return visitForInStatement(node); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return visitForOfStatement(node); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return visitExpressionStatement(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 254 /* ShorthandPropertyAssignment */: + case 256 /* CatchClause */: + return visitCatchClause(node); + case 258 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return visitNewExpression(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 188 /* BinaryExpression */: + case 192 /* 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 181 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return visitTemplateExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return visitYieldExpression(node); case 96 /* SuperKeyword */: return visitSuperKeyword(); - case 191 /* YieldExpression */: + case 195 /* 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 261 /* SourceFile */: return visitSourceFileNode(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -46926,7 +49099,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181 /* ArrowFunction */) { + if (currentNode.kind !== 185 /* ArrowFunction */) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { enclosingNonAsyncFunctionBody = currentNode; @@ -46937,14 +49110,14 @@ var ts; // variable statements, variable declarations, binding elements, and binding // patterns. switch (currentNode.kind) { - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: enclosingVariableStatement = currentNode; break; - case 220 /* VariableDeclarationList */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 224 /* VariableDeclarationList */: + case 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: break; default: enclosingVariableStatement = undefined; @@ -46973,7 +49146,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -46998,13 +49171,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 === 215 /* 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 === 215 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -47015,7 +49188,7 @@ var ts; } } else { - if (node.kind === 211 /* BreakStatement */) { + if (node.kind === 215 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -47059,33 +49232,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. @@ -47140,7 +49309,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 @@ -47175,7 +49344,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); @@ -47199,7 +49368,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)); } } @@ -47216,7 +49385,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); @@ -47267,8 +49436,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); @@ -47277,7 +49446,10 @@ var ts; statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); + var body = saveStateAndInvoke(constructor, function (constructor) { + isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; + return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); + }); ts.addRange(statements, body); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. @@ -47304,17 +49476,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 212 /* ReturnStatement */) { + if (statement.kind === 216 /* ReturnStatement */) { return true; } - else if (statement.kind === 204 /* IfStatement */) { + else if (statement.kind === 208 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200 /* Block */) { + else if (statement.kind === 204 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -47331,7 +49503,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 */; } @@ -47346,7 +49518,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 */; } @@ -47372,7 +49544,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 === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -47383,7 +49555,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 */; @@ -47409,14 +49581,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); @@ -47425,158 +49607,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_32 = 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_32)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_32, 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. @@ -47588,20 +49618,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 203 /* 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: @@ -47707,7 +49737,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); @@ -47731,7 +49761,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); } @@ -47744,91 +49774,17 @@ var ts; */ function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181 /* ArrowFunction */) { + if (node.kind !== 185 /* 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. * @@ -47837,9 +49793,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 183 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -47855,10 +49811,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 183 /* ParenthesizedExpression */: return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); } @@ -47887,7 +49843,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)); @@ -47920,7 +49876,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 @@ -47986,8 +49942,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -48068,118 +50024,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. @@ -48195,8 +50040,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; } @@ -48262,11 +50107,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -48315,7 +50160,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 */; @@ -48324,14 +50169,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 @@ -48413,7 +50258,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 /* LabeledStatement */ + statements.push(currentParent.kind === 219 /* LabeledStatement */ ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -48519,7 +50364,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 }); @@ -48541,20 +50386,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 257 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -48608,6 +50453,19 @@ var ts; } return expression; } + function visitCatchClause(node) { + ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + function addStatementToStartOfBlock(block, statement) { + var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); + return ts.updateBlock(block, [statement].concat(transformedStatements)); + } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a * PropertyAssignment. @@ -48670,7 +50528,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) @@ -48716,7 +50574,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) // @@ -48727,7 +50585,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. @@ -48742,36 +50600,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 !== 175 /* 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); } /** @@ -48928,7 +50786,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 175 /* CallExpression */ + && currentParent.kind !== 179 /* CallExpression */ ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -48937,7 +50795,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); @@ -48976,21 +50834,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(185 /* ArrowFunction */); + context.enableEmitNotification(184 /* FunctionExpression */); + context.enableEmitNotification(225 /* 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); @@ -49025,10 +50882,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 174 /* BindingElement */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 223 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -49075,44 +50932,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_33 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_33, emitFlags); - } - return name_33; - } - 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) { @@ -49124,11 +50945,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 !== 207 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -49136,7 +50957,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 !== 196 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -49378,7 +51199,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; @@ -49398,10 +51219,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 { @@ -49415,13 +51236,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205 /* DoStatement */: + case 209 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return visitWhileStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return visitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -49434,30 +51255,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitVariableStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return visitForInStatement(node); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return visitBreakStatement(node); - case 210 /* ContinueStatement */: + case 214 /* ContinueStatement */: return visitContinueStatement(node); - case 212 /* ReturnStatement */: + case 216 /* 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 { @@ -49472,21 +51293,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return visitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return visitConditionalExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return visitYieldExpression(node); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -49499,9 +51320,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -49662,7 +51483,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; } @@ -49730,7 +51551,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -49742,7 +51563,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 178 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -50111,35 +51932,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200 /* Block */: + case 204 /* Block */: return transformAndEmitBlock(node); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return transformAndEmitIfStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return transformAndEmitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return transformAndEmitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 210 /* ContinueStatement */: + case 214 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return transformAndEmitWithStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -50559,7 +52380,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 === 254 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -50572,7 +52393,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 === 253 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -50703,7 +52524,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; @@ -50733,9 +52554,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_34) { - var clone_8 = ts.getMutableClone(name_34); + 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; @@ -51137,7 +52958,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]; } @@ -51146,7 +52967,7 @@ var ts; } return expression; } - return ts.createNode(194 /* OmittedExpression */); + return ts.createOmittedExpression(); } /** * Creates a numeric literal for the provided instruction. @@ -51331,7 +53152,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 */) @@ -51708,1909 +53529,6 @@ var ts; ts.transformGenerators = transformGenerators; var _a; })(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_35 = names_1[_i]; - addExportMemberAssignments(statements, name_35); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_36 = node.name; - if (ts.isIdentifier(name_36)) { - names.push(name_36); - } - } - 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_37 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), - /*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_1 = externalImports; _b < externalImports_1.length; _b++) { - var importNode = externalImports_1[_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*/ -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_2 = externalImports; _i < externalImports_2.length; _i++) { - var externalImport = externalImports_2[_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_3 = externalImports; _b < externalImports_3.length; _b++) { - var externalImport = externalImports_3[_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_38 = 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_38, - /*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_38); - } - 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_39 = 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_39); - } - return [ - node, - createExportStatement(name_39, name_39) - ]; - } - 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 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*/ @@ -53624,8 +53542,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(253 /* PropertyAssignment */); + context.enableSubstitution(177 /* PropertyAccessExpression */); + context.enableSubstitution(257 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -53690,9 +53608,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 234 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 240 /* 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(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(261 /* 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 === 241 /* 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 !== 241 /* 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 235 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 234 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 241 /* 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 235 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 234 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 241 /* ExportDeclaration */: + // ExportDeclarations are elided as they are handled via + // `appendExportsOfDeclaration`. + return undefined; + case 240 /* 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 === 261 /* 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 === 205 /* 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 237 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238 /* 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 205 /* VariableStatement */: + return visitVariableStatement(node); + case 225 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 226 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 211 /* ForStatement */: + return visitForStatement(node); + case 212 /* ForInStatement */: + return visitForInStatement(node); + case 213 /* ForOfStatement */: + return visitForOfStatement(node); + case 209 /* DoStatement */: + return visitDoStatement(node); + case 210 /* WhileStatement */: + return visitWhileStatement(node); + case 219 /* LabeledStatement */: + return visitLabeledStatement(node); + case 217 /* WithStatement */: + return visitWithStatement(node); + case 218 /* SwitchStatement */: + return visitSwitchStatement(node); + case 232 /* CaseBlock */: + return visitCaseBlock(node); + case 253 /* CaseClause */: + return visitCaseClause(node); + case 254 /* DefaultClause */: + return visitDefaultClause(node); + case 221 /* TryStatement */: + return visitTryStatement(node); + case 256 /* CatchClause */: + return visitCatchClause(node); + case 204 /* Block */: + return visitBlock(node); + case 294 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 295 /* 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 === 192 /* 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 === 261 /* 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 === 261 /* 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 192 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 190 /* PrefixUnaryExpression */: + case 191 /* 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 === 191 /* 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 === 191 /* 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 === 261 /* 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(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(261 /* 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 235 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 234 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 241 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 240 /* ExportAssignment */: + return visitExportAssignment(node); + case 205 /* VariableStatement */: + return visitVariableStatement(node); + case 225 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 226 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 294 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 295 /* 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 === 205 /* 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 237 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238 /* 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 === 261 /* 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 192 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 191 /* PostfixUnaryExpression */: + case 190 /* 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 === 261 /* 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 === 191 /* 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 = {})); /// /// /// +/// /// /// /// @@ -53723,10 +56084,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); } @@ -53737,6 +56100,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); } @@ -53754,7 +56120,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289 /* Count */); + var enabledSyntaxKindFeatures = new Array(296 /* Count */); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -54154,7 +56520,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 !== 292 /* NotEmittedStatement */ && (emitFlags & 512 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -54167,7 +56533,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 /* NotEmittedStatement */ + if (node.kind !== 292 /* NotEmittedStatement */ && (emitFlags & 1024 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -54346,7 +56712,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 292 /* 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 @@ -54365,7 +56731,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 === 224 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -54619,7 +56985,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? ts.noop : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -54675,7 +57041,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 === 235 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -54749,10 +57115,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219 /* VariableDeclaration */) { + if (declaration.kind === 223 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { + else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -54770,7 +57136,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 === 235 /* 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; @@ -54780,12 +57146,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -54903,43 +57269,49 @@ 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 171 /* LiteralType */: return writeTextOfNode(currentText, type); - case 195 /* ExpressionWithTypeArguments */: + case 199 /* 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 emitIndexedAccessType(type); + case 170 /* MappedType */: + return emitMappedType(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) { @@ -54947,8 +57319,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); @@ -54957,14 +57329,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 === 234 /* 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 === 177 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -55010,6 +57382,42 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitIndexedAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } + function emitMappedType(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + writeEntityName(node.typeParameter.name); + write(" in "); + emitType(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emitType(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + enclosingDeclaration = prevEnclosingDeclaration; + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -55043,9 +57451,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; } } } @@ -55092,10 +57500,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 /* ImportEqualsDeclaration */ || - (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 234 /* ImportEqualsDeclaration */ || + (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -55105,7 +57513,7 @@ var ts; }); } else { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 235 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -55123,23 +57531,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return writeVariableStatement(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return writeClassDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -55147,7 +57555,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 === 261 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -55156,7 +57564,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -55208,7 +57616,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 237 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -55232,7 +57640,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 === 237 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -55253,13 +57661,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 !== 230 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 230 /* ImportEqualsDeclaration */) { + if (parent.kind === 234 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226 /* ModuleDeclaration */) { + else if (parent.kind === 230 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -55329,7 +57737,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227 /* ModuleBlock */) { + while (node.body && node.body.kind !== 231 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -55399,7 +57807,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) { @@ -55410,15 +57818,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 { @@ -55429,31 +57837,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 226 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223 /* InterfaceDeclaration */: + case 227 /* 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 === 226 /* 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 225 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -55491,7 +57899,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 === 226 /* 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 : @@ -55575,7 +57983,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 !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -55586,11 +57994,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)) { @@ -55603,14 +58011,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 223 /* 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 ? @@ -55619,7 +58027,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 === 226 /* 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 : @@ -55651,7 +58059,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 !== 198 /* OmittedExpression */) { elements.push(element); } } @@ -55721,7 +58129,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; @@ -55734,7 +58142,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 @@ -55743,7 +58151,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 ? @@ -55793,17 +58201,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 === 225 /* 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 === 225 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149 /* Constructor */) { + else if (node.kind === 150 /* Constructor */) { write("constructor"); } else { @@ -55823,17 +58231,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 @@ -55848,22 +58256,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; @@ -55877,26 +58285,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 */ ? @@ -55904,7 +58312,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 === 226 /* 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 : @@ -55918,7 +58326,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221 /* FunctionDeclaration */: + case 225 /* 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 : @@ -55953,9 +58361,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 */)) { @@ -55971,24 +58379,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 */ ? @@ -55996,7 +58404,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 === 226 /* 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 : @@ -56009,7 +58417,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 225 /* 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 : @@ -56021,12 +58429,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 === 172 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -56037,7 +58445,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194 /* OmittedExpression */) { + if (bindingElement.kind === 198 /* 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) @@ -56046,7 +58454,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 170 /* BindingElement */) { + else if (bindingElement.kind === 174 /* 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" @@ -56085,40 +58493,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 225 /* FunctionDeclaration */: + case 230 /* ModuleDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 227 /* InterfaceDeclaration */: + case 226 /* ClassDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 229 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 237 /* ExportDeclaration */: + case 241 /* 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 260 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* SourceFile */: + case 261 /* SourceFile */: return emitSourceFile(node); } } @@ -56209,6 +58617,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 @@ -56306,6 +58715,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -56499,7 +58909,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 256 /* SourceFile */: + case 261 /* SourceFile */: return emitSourceFile(node); } } @@ -56555,210 +58965,218 @@ 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 199 /* 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 emitIndexedAccessType(node); + case 170 /* MappedType */: + return emitMappedType(node); + case 171 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 168 /* ObjectBindingPattern */: + case 172 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 169 /* ArrayBindingPattern */: + case 173 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 170 /* BindingElement */: + case 174 /* BindingElement */: return emitBindingElement(node); // Misc - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: return emitTemplateSpan(node); - case 199 /* SemicolonClassElement */: + case 203 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 200 /* Block */: + case 204 /* Block */: return emitBlock(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return emitVariableStatement(node); - case 202 /* EmptyStatement */: + case 206 /* EmptyStatement */: return emitEmptyStatement(); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return emitExpressionStatement(node); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return emitIfStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return emitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return emitWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return emitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return emitForInStatement(node); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return emitForOfStatement(node); - case 210 /* ContinueStatement */: + case 214 /* ContinueStatement */: return emitContinueStatement(node); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return emitBreakStatement(node); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return emitReturnStatement(node); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return emitWithStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return emitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return emitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return emitThrowStatement(node); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return emitTryStatement(node); - case 218 /* DebuggerStatement */: + case 222 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return emitClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return emitModuleBlock(node); - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: return emitCaseBlock(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return emitImportDeclaration(node); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return emitImportClause(node); - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: return emitNamespaceImport(node); - case 234 /* NamedImports */: + case 238 /* NamedImports */: return emitNamedImports(node); - case 235 /* ImportSpecifier */: + case 239 /* ImportSpecifier */: return emitImportSpecifier(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return emitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return emitExportDeclaration(node); - case 238 /* NamedExports */: + case 242 /* NamedExports */: return emitNamedExports(node); - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: return emitExportSpecifier(node); - case 240 /* MissingDeclaration */: + case 244 /* MissingDeclaration */: return; // Module references - case 241 /* ExternalModuleReference */: + case 245 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: return emitJsxAttribute(node); - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 249 /* CaseClause */: + case 253 /* CaseClause */: return emitCaseClause(node); - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: return emitDefaultClause(node); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: return emitHeritageClause(node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); + case 259 /* SpreadAssignment */: + return emitSpreadAssignment(node); // Enum - case 255 /* EnumMember */: + case 260 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -56795,65 +59213,65 @@ var ts; writeTokenText(kind); return; // Expressions - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return emitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return emitNewExpression(node); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 178 /* TypeAssertionExpression */: + case 182 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return emitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return emitArrowFunction(node); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return emitDeleteExpression(node); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return emitVoidExpression(node); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return emitAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return emitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return emitConditionalExpression(node); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return emitTemplateExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return emitYieldExpression(node); - case 192 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 193 /* ClassExpression */: + case 196 /* SpreadElement */: + return emitSpreadExpression(node); + case 197 /* ClassExpression */: return emitClassExpression(node); - case 194 /* OmittedExpression */: + case 198 /* OmittedExpression */: return; - case 196 /* AsExpression */: + case 200 /* AsExpression */: return emitAsExpression(node); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 242 /* JsxElement */: + case 246 /* JsxElement */: return emitJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } @@ -56979,7 +59397,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); } @@ -57067,6 +59485,39 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitIndexedAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } + function emitMappedType(node) { + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + emit(node.typeParameter.name); + write(" in "); + emit(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emit(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -57253,7 +59704,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 === 190 /* 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 */))); } @@ -57297,7 +59748,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -57371,7 +59822,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 204 /* IfStatement */) { + if (node.elseStatement.kind === 208 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -57433,7 +59884,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220 /* VariableDeclarationList */) { + if (node.kind === 224 /* VariableDeclarationList */) { emit(node); } else { @@ -57672,7 +60123,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 === 230 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -57912,6 +60363,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } // // Enum // @@ -57997,10 +60454,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) { @@ -58346,7 +60810,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 183 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -58409,10 +60873,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) { @@ -58420,11 +60884,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; } } } @@ -58473,17 +60937,17 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: + case 229 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 231 /* ImportDeclaration */: - case 237 /* ExportDeclaration */: + case 235 /* ImportDeclaration */: + case 241 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: - case 236 /* ExportAssignment */: + case 225 /* FunctionDeclaration */: + case 226 /* ClassDeclaration */: + case 240 /* ExportAssignment */: return generateNameForExportDefault(); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58650,7 +61114,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.1.0"; + ts.version = "2.2.0"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -58876,11 +61340,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; @@ -58901,7 +61365,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. @@ -58918,7 +61382,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; }; @@ -58991,6 +61463,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -58998,13 +61471,14 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); return program; function getCommonSourceDirectory() { - if (typeof commonSourceDirectory === "undefined") { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + if (commonSourceDirectory === undefined) { + var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } else { - commonSourceDirectory = computeCommonSourceDirectory(files); + commonSourceDirectory = computeCommonSourceDirectory(emittedFiles); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { // Make sure directory path ends with directory separator so this string can directly @@ -59027,6 +61501,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; @@ -59034,21 +61614,7 @@ var ts; // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.moduleResolution !== options.moduleResolution) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx) || - (oldOptions.allowJs !== options.allowJs) || - (oldOptions.rootDir !== options.rootDir) || - (oldOptions.configFilePath !== options.configFilePath) || - (oldOptions.baseUrl !== options.baseUrl) || - (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || - !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || - !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || - !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !ts.equalOwnProperties(oldOptions.paths, options.paths)) { + if (ts.changesAffectModuleResolution(oldOptions, options)) { return false; } ts.Debug.assert(!oldProgram.structureIsReused); @@ -59099,29 +61665,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 @@ -59130,15 +61675,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; @@ -59154,11 +61726,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)); } @@ -59247,6 +61822,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) { @@ -59275,179 +61858,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 223 /* 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 234 /* ImportEqualsDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 240 /* 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 255 /* 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 227 /* InterfaceDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 230 /* ModuleDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 228 /* TypeAliasDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 229 /* EnumDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 182 /* 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 226 /* ClassDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: + case 225 /* 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 205 /* VariableStatement */: + // Check modifiers + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 205 /* 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 179 /* CallExpression */: + case 180 /* NewExpression */: + case 199 /* 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); } }); } @@ -59455,8 +62039,7 @@ var ts; return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -59473,9 +62056,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); } @@ -59494,16 +62074,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(235 /* ImportDeclaration */); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -59515,12 +62100,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 235 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 241 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -59535,7 +62121,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226 /* ModuleDeclaration */: + case 230 /* 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. @@ -59547,6 +62133,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. @@ -59572,13 +62162,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("', '") + "'"]; @@ -59644,7 +62231,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); } @@ -59725,9 +62312,12 @@ var ts; // If we already resolved to this file, it must have been a secondary reference. Check file contents // for sameness and possibly issue an error if (previousResolution) { - var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); - if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + // Don't bother reading the file again if it's the same file. + if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { + var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); + if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + } } // don't overwrite previous resolution result saveResolution = false; @@ -59764,29 +62354,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--; @@ -59797,7 +62397,6 @@ var ts; // no imports - drop cached module resolutions file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -59958,7 +62557,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 @@ -59976,12 +62583,18 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + 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)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); } else { emitFilesSeen.set(emitFilePath, true); @@ -59989,12 +62602,40 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, message) { + function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + 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 = {})); /// /// @@ -60075,6 +62716,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", @@ -60263,6 +62909,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, @@ -60426,7 +63073,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 @@ -60580,7 +63228,13 @@ var ts; i++; break; case "boolean": - options[opt.name] = true; + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } break; case "string": options[opt.name] = args[i] || ""; @@ -60717,11 +63371,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": @@ -60729,14 +63383,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") { @@ -60745,11 +63399,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); } } } @@ -60879,6 +63533,9 @@ var ts; if (ts.hasProperty(json, "files")) { if (ts.isArray(json["files"])) { fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); @@ -60916,7 +63573,11 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; } var _b; } @@ -60952,9 +63613,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; } @@ -61186,6 +63845,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: @@ -61199,14 +63859,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; @@ -61228,6 +63887,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. @@ -61331,12 +64003,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"; @@ -61360,14 +64033,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"; @@ -61376,8 +64049,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"; @@ -61388,8 +64061,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) { @@ -61496,6 +64168,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"; @@ -61521,52 +64194,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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: + case 260 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 256 /* CatchClause */: return 1 /* Value */; - case 142 /* TypeParameter */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 160 /* TypeLiteral */: + case 143 /* TypeParameter */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 161 /* TypeLiteral */: return 2 /* Type */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -61576,22 +64248,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 238 /* NamedImports */: + case 239 /* ImportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportDeclaration */: + case 240 /* ExportAssignment */: + case 241 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 256 /* SourceFile */: + case 261 /* 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 === 240 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -61616,15 +64288,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 === 234 /* 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; @@ -61635,27 +64307,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 === 177 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 177 /* 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 === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* 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 === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -61663,17 +64335,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 === 199 /* 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, 179 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 180 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -61686,7 +64358,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -61696,13 +64368,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 === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 215 /* LabeledStatement */ && + node.parent.kind === 219 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -61710,15 +64382,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 === 177 /* 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 === 230 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -61729,19 +64401,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 257 /* PropertyAssignment */: + case 260 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 230 /* ModuleDeclaration */: return node.parent.name === node; - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return true; } } @@ -61790,17 +64462,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 261 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: return node; } } @@ -61808,46 +64480,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 197 /* 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 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 223 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 170 /* BindingElement */: + case 174 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* 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 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 234 /* ImportEqualsDeclaration */: + case 239 /* ImportSpecifier */: + case 236 /* ImportClause */: + case 243 /* ExportSpecifier */: + case 237 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -61862,7 +64534,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 === 171 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -61877,7 +64549,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; } @@ -61922,42 +64594,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 176 /* ObjectLiteralExpression */: + case 172 /* ObjectBindingPattern */: + case 161 /* TypeLiteral */: + case 204 /* Block */: + case 231 /* ModuleBlock */: + case 232 /* CaseBlock */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 176 /* NewExpression */: + case 180 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 175 /* CallExpression */: - case 179 /* ParenthesizedExpression */: - case 165 /* ParenthesizedType */: + case 179 /* CallExpression */: + case 183 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 185 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -61967,67 +64639,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 230 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 204 /* IfStatement */: + case 208 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203 /* ExpressionStatement */: + case 207 /* 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 175 /* ArrayLiteralExpression */: + case 173 /* ArrayBindingPattern */: + case 178 /* 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 253 /* CaseClause */: + case 254 /* 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 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 210 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 205 /* DoStatement */: + case 209 /* 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 187 /* TypeOfExpression */: + case 186 /* DeleteExpression */: + case 188 /* VoidExpression */: + case 195 /* YieldExpression */: + case 196 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 237 /* ExportDeclaration */: - case 231 /* ImportDeclaration */: + case 241 /* ExportDeclaration */: + case 235 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -62083,7 +64755,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 === 291 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -62255,7 +64927,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 261 /* 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. @@ -62314,17 +64986,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { return true; } return false; @@ -62436,17 +65108,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 === 179 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* 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) { @@ -62505,18 +65177,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 /* ArrayLiteralExpression */ || - node.kind === 172 /* ObjectLiteralExpression */) { + if (node.kind === 175 /* ArrayLiteralExpression */ || + node.kind === 176 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 188 /* BinaryExpression */ && + if (node.parent.kind === 192 /* 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 === 213 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -62524,7 +65196,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 === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -62557,7 +65229,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(); @@ -62579,8 +65251,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; function writeIndent() { if (lineStart) { @@ -62737,7 +65409,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' @@ -62749,7 +65421,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 === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -62821,7 +65493,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 @@ -62864,7 +65536,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". @@ -63023,10 +65695,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, @@ -63198,7 +65870,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)) { @@ -63255,10 +65927,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 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 225 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -63309,7 +65981,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 /* ModuleDeclaration */ && + return declaration.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -63388,8 +66060,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 */ }; @@ -63473,16 +66145,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 280 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 278 /* JSDocTemplateTag */: + case 283 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 277 /* JSDocTypeTag */: + case 282 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 276 /* JSDocReturnTag */: + case 281 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -63569,22 +66241,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -63612,17 +66284,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 === 223 /* VariableDeclaration */ || + token.parent.kind === 147 /* PropertyDeclaration */ || + token.parent.kind === 144 /* Parameter */ || + token.parent.kind === 250 /* 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 === 192 /* BinaryExpression */ || + token.parent.kind === 190 /* PrefixUnaryExpression */ || + token.parent.kind === 191 /* PostfixUnaryExpression */ || + token.parent.kind === 193 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -63632,7 +66304,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 === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -63648,32 +66320,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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 227 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 226 /* ModuleDeclaration */: + case 230 /* 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 */; } @@ -63733,7 +66405,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 === 249 /* 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: @@ -63760,14 +66432,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, @@ -63827,8 +66499,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 === 257 /* PropertyAssignment */ && + node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -63853,7 +66525,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 === 235 /* 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*/"); @@ -63925,7 +66597,7 @@ var ts; if (!type) { return; } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); } else { @@ -64280,11 +66952,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_16; + currentDir = parent_14; } else { break; @@ -64436,9 +67108,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277 /* JSDocTypeTag */: - case 275 /* JSDocParameterTag */: - case 276 /* JSDocReturnTag */: + case 282 /* JSDocTypeTag */: + case 280 /* JSDocParameterTag */: + case 281 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -64483,13 +67155,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_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_17.kind === 173 /* PropertyAccessExpression */) { + if (parent_15.kind === 177 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140 /* QualifiedName */) { + else if (parent_15.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -64504,7 +67176,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 === 249 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -64553,7 +67225,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 === 177 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -64581,7 +67253,7 @@ var ts; symbols.push(symbol); } } - if (isJavaScriptFile && type.flags & 524288 /* Union */) { + if (isJavaScriptFile && type.flags & 65536 /* Union */) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers @@ -64609,7 +67281,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -64657,9 +67329,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 === 261 /* SourceFile */ || + scopeNode.kind === 194 /* TemplateExpression */ || + scopeNode.kind === 252 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -64692,11 +67364,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 248 /* 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 === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; } } return false; @@ -64706,40 +67378,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 === 179 /* CallExpression */ // func( a, | + || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 180 /* NewExpression */ // new C(a, | + || containingNodeKind === 175 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 192 /* 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 === 179 /* CallExpression */ // func( | + || containingNodeKind === 150 /* Constructor */ // constructor( | + || containingNodeKind === 180 /* NewExpression */ // new C(a| + || containingNodeKind === 183 /* 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 === 175 /* 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 === 230 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 188 /* BinaryExpression */; // x = a| + return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 192 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 202 /* 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()) { @@ -64782,7 +67454,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 176 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -64792,7 +67464,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 172 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -64803,11 +67475,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); } } @@ -64849,9 +67521,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 === 238 /* NamedImports */ ? + 235 /* ImportDeclaration */ : + 241 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -64876,9 +67548,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_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { + return parent_16; } break; } @@ -64895,8 +67567,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: return contextToken.parent; } } @@ -64905,37 +67577,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_17 = 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 250 /* JsxAttribute */: + case 251 /* JsxSpreadAttribute */: + if (parent_17 && (parent_17.kind === 247 /* JsxSelfClosingElement */ || parent_17.kind === 248 /* JsxOpeningElement */)) { + return parent_17; } - else if (parent_19.kind === 246 /* JsxAttribute */) { - return parent_19.parent; + else if (parent_17.kind === 250 /* JsxAttribute */) { + return parent_17.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_17 && ((parent_17.kind === 250 /* JsxAttribute */) || (parent_17.kind === 251 /* JsxSpreadAttribute */))) { + return parent_17.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_17 && + parent_17.kind === 252 /* JsxExpression */ && + parent_17.parent && + (parent_17.parent.kind === 250 /* JsxAttribute */)) { + return parent_17.parent.parent; } - if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { - return parent_19.parent; + if (parent_17 && parent_17.kind === 251 /* JsxSpreadAttribute */) { + return parent_17.parent; } break; } @@ -64944,16 +67616,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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* 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; @@ -64965,66 +67637,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 === 223 /* VariableDeclaration */ || + containingNodeKind === 224 /* VariableDeclarationList */ || + containingNodeKind === 205 /* VariableStatement */ || + containingNodeKind === 229 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 222 /* ClassDeclaration */ || - containingNodeKind === 193 /* ClassExpression */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 169 /* ArrayBindingPattern */ || - containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 226 /* ClassDeclaration */ || + containingNodeKind === 197 /* ClassExpression */ || + containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 173 /* ArrayBindingPattern */ || + containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 170 /* BindingElement */; // var {x :html| + return containingNodeKind === 174 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 252 /* CatchClause */ || + return containingNodeKind === 256 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 225 /* EnumDeclaration */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* TypeLiteral */; // const x : { | + return containingNodeKind === 229 /* EnumDeclaration */ || + containingNodeKind === 227 /* 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 === 227 /* 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 === 226 /* ClassDeclaration */ || + containingNodeKind === 197 /* ClassExpression */ || + containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 228 /* 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 === 173 /* 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 === 239 /* ImportSpecifier */ || + containingNodeKind === 243 /* ExportSpecifier */ || + containingNodeKind === 237 /* 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. @@ -65072,8 +67744,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"; }); @@ -65094,10 +67766,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 !== 257 /* PropertyAssignment */ && + m.kind !== 258 /* ShorthandPropertyAssignment */ && + m.kind !== 174 /* 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 @@ -65105,7 +67779,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 170 /* BindingElement */ && m.propertyName) { + if (m.kind === 174 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -65135,7 +67809,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246 /* JsxAttribute */) { + if (attr.kind === 250 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -65185,7 +67859,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, @@ -65262,7 +67936,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)) { @@ -65316,75 +67990,75 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 204 /* IfStatement */)) { + if (hasKind(node.parent, 208 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 212 /* ReturnStatement */)) { + if (hasKind(node.parent, 216 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 216 /* ThrowStatement */)) { + if (hasKind(node.parent, 220 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 217 /* TryStatement */)) { + if (hasKind(parent(node), 221 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 214 /* SwitchStatement */)) { + if (hasKind(node.parent, 218 /* 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))), 218 /* 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, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* 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, 211 /* ForStatement */) || + hasKind(node.parent, 212 /* ForInStatement */) || + hasKind(node.parent, 213 /* 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, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* 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 === 205 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -65400,10 +68074,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216 /* ThrowStatement */) { + if (node.kind === 220 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 217 /* TryStatement */) { + else if (node.kind === 221 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -65430,19 +68104,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_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 261 /* SourceFile */) { + return parent_18; } // 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_18.kind === 221 /* TryStatement */) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_18; } return undefined; } @@ -65451,7 +68125,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { + if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -65466,16 +68140,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 218 /* SwitchStatement */: + if (statement.kind === 214 /* ContinueStatement */) { continue; } // Fall through. - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 210 /* WhileStatement */: + case 209 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -65494,24 +68168,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 === 226 /* ClassDeclaration */ || + container.kind === 197 /* 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 === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { + if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { return undefined; } } @@ -65523,8 +68197,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: + case 231 /* ModuleBlock */: + case 261 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -65533,17 +68207,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 226 /* ClassDeclaration */: + case 197 /* 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); @@ -65596,13 +68270,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 */); }); } } } @@ -65620,7 +68294,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 === 209 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -65641,13 +68315,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 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -65701,7 +68375,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, 204 /* Block */))) { return undefined; } var keywords = []; @@ -65717,7 +68391,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, 208 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -65730,7 +68404,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 208 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -65773,7 +68447,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 === 219 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -66007,12 +68681,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, 236 /* 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 === 239 /* ImportSpecifier */ || + declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -66020,7 +68694,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 === 239 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -66035,14 +68709,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 172 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -66072,14 +68746,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 === 184 /* FunctionExpression */ || valueDeclaration.kind === 197 /* 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, 226 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -66110,7 +68784,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 256 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 261 /* 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; @@ -66141,8 +68815,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); } @@ -66274,7 +68948,7 @@ var ts; if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { return [localParentType.symbol]; } - else if (localParentType.flags & 1572864 /* UnionOrIntersection */) { + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { return getSymbolsForClassAndInterfaceComponents(localParentType); } } @@ -66314,14 +68988,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) { @@ -66344,7 +69018,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) { @@ -66386,7 +69060,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -66399,24 +69073,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_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.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_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 204 /* Block */) { + ts.forEachReturnStatement(parent_19.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_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -66438,7 +69112,7 @@ var ts; if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { result.push(componentType.symbol); } - if (componentType.getFlags() & 1572864 /* UnionOrIntersection */) { + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { getSymbolsForClassAndInterfaceComponents(componentType, result); } } @@ -66456,12 +69130,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 /* ExpressionWithTypeArguments */ - && node.parent.kind === 251 /* HeritageClause */ + if (node.kind === 199 /* ExpressionWithTypeArguments */ + && node.parent.kind === 255 /* 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 === 177 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -66472,14 +69146,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 183 /* 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 === 185 /* ArrowFunction */ || + node.kind === 184 /* FunctionExpression */ || + node.kind === 176 /* ObjectLiteralExpression */ || + node.kind === 197 /* ClassExpression */ || + node.kind === 175 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -66528,7 +69202,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 227 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -66556,13 +69230,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; @@ -66594,27 +69268,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 261 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 184 /* 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. @@ -66623,7 +69297,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256 /* SourceFile */) { + if (searchSpaceNode.kind === 261 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -66657,28 +69331,28 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 225 /* 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 197 /* ClassExpression */: + case 226 /* 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 261 /* SourceFile */: + if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -66718,8 +69392,8 @@ var ts; if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { references.push(getReferenceEntryFromNode(node_2)); } } @@ -66732,7 +69406,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 !== 258 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -66780,7 +69454,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)); } @@ -66835,7 +69509,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 227 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -66919,7 +69593,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)) { @@ -66939,7 +69613,7 @@ var ts; if (symbol_2) { result_4.push(symbol_2); } - if (contextualType.flags & 524288 /* Union */) { + if (contextualType.flags & 65536 /* Union */) { ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -67001,7 +69675,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219 /* VariableDeclaration */) { + else if (node.kind === 223 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -67011,18 +69685,18 @@ var ts; } else { switch (node.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 229 /* EnumDeclaration */: + case 230 /* 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 === 205 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); return node.parent.parent; } } @@ -67061,10 +69735,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { + if (parent.kind === 191 /* PostfixUnaryExpression */ || parent.kind === 190 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 192 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -67086,7 +69760,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 @@ -67097,11 +69771,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 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return true; } return false; @@ -67176,7 +69850,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { + (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -67185,7 +69859,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 === 258 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -67213,7 +69887,7 @@ var ts; if (!type) { return undefined; } - if (type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */)) { + if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { @@ -67268,8 +69942,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 === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -67349,7 +70023,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 === 258 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -67515,19 +70189,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 225 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: + case 226 /* ClassDeclaration */: + case 205 /* VariableStatement */: break findOwner; - case 256 /* SourceFile */: + case 261 /* SourceFile */: return undefined; - case 226 /* ModuleDeclaration */: + case 230 /* 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 === 230 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -67568,7 +70242,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201 /* VariableStatement */) { + if (commentOwner.kind === 205 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -67586,17 +70260,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 === 183 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return rightHandSide.parameters; - case 193 /* ClassExpression */: + case 197 /* 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; } } @@ -67622,6 +70296,16 @@ var ts; // that we are confident require typings var safeList; var EmptySafeList = ts.createMap(); + /* @internal */ + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project @@ -67631,7 +70315,7 @@ var ts; * @param typingOptions are used to customize the typing inference process * @param compilerOptions are used as a source for typing inference */ - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, unresolvedImports) { // A typing name to typing file path mapping var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { @@ -67653,7 +70337,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); @@ -67667,15 +70351,25 @@ var ts; getTypingNamesFromNodeModuleFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); + // add typings for unresolved imports + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } + } + } // 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 - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; delete inferredTypings[excludeTypingName]; } var newTypingNames = []; @@ -67707,10 +70401,12 @@ var ts; * Get the typing info from common package manager json files like package.json or bower.json */ function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); if (result.config) { var jsonConfig = result.config; - filesToWatch.push(jsonPath); if (jsonConfig.dependencies) { mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); } @@ -67806,12 +70502,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; } @@ -67824,14 +70520,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 }); } } } @@ -67839,7 +70535,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 === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -67881,7 +70577,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 { @@ -67902,7 +70598,7 @@ var ts; } return true; } - if (expression.kind === 173 /* PropertyAccessExpression */) { + if (expression.kind === 177 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -67915,7 +70611,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; } @@ -68068,7 +70764,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); @@ -68080,21 +70776,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 236 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -68106,7 +70802,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 237 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -68117,12 +70813,12 @@ var ts; } } break; - case 170 /* BindingElement */: - case 219 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 223 /* 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. @@ -68132,12 +70828,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -68147,9 +70843,9 @@ var ts; } endNode(); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -68157,21 +70853,21 @@ var ts; } endNode(); break; - case 226 /* ModuleDeclaration */: + case 230 /* 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 243 /* ExportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 155 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 228 /* 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 === 284 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -68222,14 +70918,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 !== 230 /* 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 !== 230 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -68289,7 +70985,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 230 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -68297,18 +70993,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 193 /* ClassExpression */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 197 /* ClassExpression */: return getFunctionOrClassName(node); - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 230 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -68319,29 +71015,32 @@ var ts; } } switch (node.kind) { - case 256 /* SourceFile */: + case 261 /* 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 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } + // We may get a string with newlines or other whitespace in the case of an object dereference + // (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 284 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -68353,7 +71052,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 205 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -68382,24 +71081,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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 229 /* EnumDeclaration */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 261 /* SourceFile */: + case 228 /* TypeAliasDeclaration */: + case 284 /* 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 223 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -68409,10 +71108,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: - case 148 /* MethodDeclaration */: - case 149 /* Constructor */: + case 231 /* ModuleBlock */: + case 261 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -68421,7 +71120,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 !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; }); } } @@ -68479,7 +71178,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 === 230 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -68490,13 +71189,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 === 230 /* 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 === 261 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -68504,14 +71203,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 === 223 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 /* BinaryExpression */ && + else if (node.parent.kind === 192 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { - return nodeText(node.parent.left); + return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -68522,8 +71221,22 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; + return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */ || node.kind === 197 /* ClassExpression */; } + /** + * Matches all whitespace characters in a string. Eg: + * + * "app. + * + * onactivated" + * + * matches because of the newline, whereas + * + * "app.onactivated" + * + * does not match. + */ + var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -68598,7 +71311,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 185 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -68610,30 +71323,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200 /* Block */: + case 204 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_20 = 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_20.kind === 209 /* DoStatement */ || + parent_20.kind === 212 /* ForInStatement */ || + parent_20.kind === 213 /* ForOfStatement */ || + parent_20.kind === 211 /* ForStatement */ || + parent_20.kind === 208 /* IfStatement */ || + parent_20.kind === 210 /* WhileStatement */ || + parent_20.kind === 217 /* WithStatement */ || + parent_20.kind === 256 /* CatchClause */) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217 /* TryStatement */) { + if (parent_20.kind === 221 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_22; + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -68656,23 +71369,23 @@ var ts; break; } // Fallthrough. - case 227 /* ModuleBlock */: { + case 231 /* 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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 176 /* ObjectLiteralExpression */: + case 232 /* 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 175 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -68692,13 +71405,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, @@ -69029,7 +71742,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 @@ -69042,7 +71755,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 @@ -69320,7 +72033,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(); @@ -69345,7 +72058,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"; @@ -69376,7 +72089,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"; @@ -69392,7 +72105,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" @@ -69422,7 +72135,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"; @@ -69434,7 +72147,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" @@ -69459,7 +72172,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(); @@ -69814,12 +72527,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 @@ -69850,7 +72563,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 179 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -69858,7 +72571,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 173 /* PropertyAccessExpression */ + : expression.kind === 177 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -69891,7 +72604,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 === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -69945,25 +72658,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 === 181 /* 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 === 181 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 194 /* 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 === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* 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 === 194 /* 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; @@ -70081,7 +72794,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 === 194 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -70090,7 +72803,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 !== 261 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -70150,7 +72863,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; @@ -70161,6 +72876,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); }); @@ -70175,7 +72891,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], @@ -70232,7 +72948,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, 197 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -70338,7 +73054,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 === 177 /* 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)) { @@ -70347,7 +73063,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 === 179 /* CallExpression */ || location.kind === 180 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -70360,7 +73076,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 === 180 /* 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 @@ -70400,7 +73116,7 @@ var ts; displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 2097152 /* Anonymous */) && type.symbol) { + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); @@ -70413,24 +73129,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); @@ -70439,7 +73155,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 197 /* 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 @@ -70462,7 +73178,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); @@ -70483,9 +73199,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 230 /* 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); } @@ -70496,36 +73212,36 @@ var ts; displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91 /* InKeyword */)); - displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter + addInPrefix(); addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } 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)) { + addInPrefix(); 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 */)); } - else { + else if (declaration.kind === 228 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); + addInPrefix(); + displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -70536,7 +73252,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255 /* EnumMember */) { + if (declaration.kind === 260 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -70548,10 +73264,10 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 233 /* 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 */)); @@ -70559,13 +73275,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230 /* ImportEqualsDeclaration */) { + if (declaration.kind === 234 /* 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 */)); @@ -70632,10 +73348,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 === 261 /* 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 !== 192 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -70656,6 +73372,11 @@ var ts; displayParts.push(ts.lineBreakPart()); } } + function addInPrefix() { + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(91 /* InKeyword */)); + displayParts.push(ts.spacePart()); + } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); @@ -70711,16 +73432,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 180 /* FunctionExpression */) { + if (declaration.kind === 184 /* FunctionExpression */) { return true; } - if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { + if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* 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_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { + if (parent_21.kind === 261 /* SourceFile */ || parent_21.kind === 231 /* ModuleBlock */) { return false; } } @@ -70831,7 +73552,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -70850,7 +73571,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_4(opt); } return options; } @@ -70862,8 +73583,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 */ @@ -70958,10 +73679,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 250 /* JsxAttribute */: + case 248 /* JsxOpeningElement */: + case 249 /* JsxClosingElement */: + case 247 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -71196,14 +73917,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 = {})); /// @@ -71235,13 +73956,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 = {})); /// @@ -71282,11 +74003,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 = {})); /// @@ -71437,7 +74158,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 */)); @@ -71445,10 +74166,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 @@ -71468,7 +74189,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 */)); @@ -71596,9 +74317,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"); @@ -71607,42 +74328,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 207 /* ForStatement */; + return context.contextNode.kind === 211 /* 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 192 /* BinaryExpression */: + case 193 /* ConditionalExpression */: + case 200 /* AsExpression */: + case 243 /* ExportSpecifier */: + case 239 /* 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 174 /* BindingElement */: // equals in type X = ... - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: // equal in p = 0; - case 143 /* Parameter */: - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 144 /* Parameter */: + case 260 /* 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 212 /* 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 213 /* ForOfStatement */: + return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; }; @@ -71650,7 +74371,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189 /* ConditionalExpression */; + return context.contextNode.kind === 193 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -71694,97 +74415,97 @@ var ts; return true; } switch (node.kind) { - case 200 /* Block */: - case 228 /* CaseBlock */: - case 172 /* ObjectLiteralExpression */: - case 227 /* ModuleBlock */: + case 204 /* Block */: + case 232 /* CaseBlock */: + case 176 /* ObjectLiteralExpression */: + case 231 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 225 /* 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 184 /* FunctionExpression */: + case 150 /* Constructor */: + case 185 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; + return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* 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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 161 /* TypeLiteral */: + case 230 /* ModuleDeclaration */: + case 241 /* ExportDeclaration */: + case 242 /* NamedExports */: + case 235 /* ImportDeclaration */: + case 238 /* 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 226 /* ClassDeclaration */: + case 230 /* ModuleDeclaration */: + case 229 /* EnumDeclaration */: + case 204 /* Block */: + case 256 /* CatchClause */: + case 231 /* ModuleBlock */: + case 218 /* 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 208 /* IfStatement */: + case 218 /* SwitchStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 210 /* WhileStatement */: + case 221 /* TryStatement */: + case 209 /* DoStatement */: + case 217 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 252 /* CatchClause */: + case 256 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172 /* ObjectLiteralExpression */; + return context.contextNode.kind === 176 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 175 /* CallExpression */; + return context.contextNode.kind === 179 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176 /* NewExpression */; + return context.contextNode.kind === 180 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -71796,25 +74517,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181 /* ArrowFunction */; + return context.contextNode.kind === 185 /* 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 !== 246 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248 /* JsxExpression */; + return context.contextNode.kind === 252 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246 /* JsxAttribute */; + return context.nextTokenParent.kind === 250 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246 /* JsxAttribute */; + return context.contextNode.kind === 250 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243 /* JsxSelfClosingElement */; + return context.contextNode.kind === 247 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -71829,41 +74550,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 === 224 /* 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 === 230 /* 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 182 /* TypeAssertionExpression */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 199 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -71874,13 +74595,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178 /* TypeAssertionExpression */; + return context.contextNode.kind === 182 /* 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 === 188 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -71904,7 +74625,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); @@ -71918,7 +74639,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; }; @@ -71955,6 +74676,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"; @@ -71962,8 +74684,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: @@ -72099,7 +74820,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; @@ -72143,9 +74864,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 */]); @@ -72153,7 +74874,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 = {})); @@ -72412,17 +75133,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 226 /* ModuleDeclaration */: + case 230 /* 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 === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 261 /* SourceFile */: + case 204 /* Block */: + case 231 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -72627,20 +75348,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 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 229 /* EnumDeclaration */: return 229 /* 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; } } @@ -72784,11 +75505,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 === 175 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -73133,12 +75854,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 185 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -73146,8 +75867,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73155,7 +75876,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 156 /* TypeReference */: + case 157 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73271,7 +75992,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 !== 192 /* 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 */) { @@ -73394,7 +76115,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 === 261 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -73427,7 +76148,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 === 208 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -73439,23 +76160,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 176 /* ObjectLiteralExpression */: return node.parent.properties; - case 171 /* ArrayLiteralExpression */: + case 175 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* 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())) { @@ -73466,8 +76187,8 @@ var ts; } break; } - case 176 /* NewExpression */: - case 175 /* CallExpression */: { + case 180 /* NewExpression */: + case 179 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -73497,8 +76218,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 === 179 /* CallExpression */ || + node.parent.kind === 180 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -73516,10 +76237,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: node = node.expression; break; default: @@ -73583,48 +76304,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 207 /* ExpressionStatement */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 175 /* ArrayLiteralExpression */: + case 204 /* Block */: + case 231 /* ModuleBlock */: + case 176 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 163 /* TupleType */: + case 232 /* CaseBlock */: + case 254 /* DefaultClause */: + case 253 /* CaseClause */: + case 183 /* ParenthesizedExpression */: + case 177 /* PropertyAccessExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 205 /* VariableStatement */: + case 223 /* VariableDeclaration */: + case 240 /* ExportAssignment */: + case 216 /* ReturnStatement */: + case 193 /* ConditionalExpression */: + case 173 /* ArrayBindingPattern */: + case 172 /* ObjectBindingPattern */: + case 248 /* JsxOpeningElement */: + case 247 /* JsxSelfClosingElement */: + case 252 /* JsxExpression */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 144 /* Parameter */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 166 /* ParenthesizedType */: + case 181 /* TaggedTemplateExpression */: + case 189 /* AwaitExpression */: + case 242 /* NamedExports */: + case 238 /* NamedImports */: + case 243 /* ExportSpecifier */: + case 239 /* ImportSpecifier */: return true; } return false; @@ -73633,27 +76354,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 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 211 /* ForStatement */: + case 208 /* IfStatement */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 185 /* ArrowFunction */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return childKind !== 204 /* Block */; + case 241 /* ExportDeclaration */: + return childKind !== 242 /* NamedExports */; + case 235 /* ImportDeclaration */: + return childKind !== 236 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); + case 246 /* JsxElement */: + return childKind !== 249 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -73743,7 +76464,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 == 179 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -73767,7 +76488,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -73812,7 +76533,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; @@ -73824,7 +76545,6 @@ var ts; this.end = end; this.flags = 0 /* None */; this.transformFlags = undefined; - this.excludeTransformFlags = undefined; this.parent = undefined; this.kind = kind; } @@ -73871,11 +76591,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(291 /* 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); } @@ -73890,11 +76610,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 >= 278 /* FirstJSDocTagNode */ && this.kind <= 290 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -73952,7 +76672,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); @@ -73960,7 +76680,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; }()); @@ -74088,7 +76808,7 @@ var ts; return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; TypeObject.prototype.getBaseTypes = function () { - return this.flags & (32768 /* Class */ | 65536 /* Interface */) + return this.flags & 32768 /* Object */ && this.objectFlags & (1 /* Class */ | 2 /* Interface */) ? this.checker.getBaseTypes(this) : undefined; }; @@ -74163,9 +76883,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 === 177 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -74185,10 +76905,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -74208,32 +76928,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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 229 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 243 /* ExportSpecifier */: + case 239 /* ImportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportClause */: + case 237 /* 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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -74242,19 +76962,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 260 /* EnumMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: addDeclaration(node); break; - case 237 /* ExportDeclaration */: + case 241 /* 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 235 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -74266,7 +76986,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 === 237 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -74421,7 +77141,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. @@ -74599,7 +77319,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function () { }, + writeFile: ts.noop, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality @@ -74796,10 +77516,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 177 /* 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); @@ -74942,15 +77662,15 @@ var ts; return; } switch (node.kind) { - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 177 /* 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 @@ -74967,7 +77687,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 === 230 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -75351,7 +78071,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 === 245 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -75371,7 +78091,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 /* ElementAccessExpression */ && + node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -75455,113 +78175,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 219 /* VariableDeclaration */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 223 /* 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 225 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 200 /* Block */: + case 204 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return spanInBlock(node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return spanInBlock(node.block); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 205 /* DoStatement */: + case 209 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 218 /* DebuggerStatement */: + case 222 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 204 /* IfStatement */: + case 208 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return spanInForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 253 /* CaseClause */: + case 254 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 217 /* TryStatement */: + case 221 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ModuleDeclaration */: + case 230 /* 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 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 260 /* EnumMember */: + case 174 /* BindingElement */: // span on complete node return textSpan(node); - case 213 /* WithStatement */: + case 217 /* 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 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -75591,7 +78311,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 @@ -75604,13 +78324,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 == 196 /* SpreadElement */ || + node.kind === 257 /* PropertyAssignment */ || + node.kind === 258 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188 /* BinaryExpression */) { + if (node.kind === 192 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -75633,22 +78353,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205 /* DoStatement */: + case 209 /* 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 211 /* ForStatement */: + case 213 /* ForOfStatement */: return textSpan(node); - case 188 /* BinaryExpression */: + case 192 /* 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 185 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -75657,13 +78377,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 === 257 /* 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 === 182 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -75671,8 +78391,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 === 223 /* VariableDeclaration */ || + node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -75680,7 +78400,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188 /* BinaryExpression */) { + if (node.parent.kind === 192 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -75706,7 +78426,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 === 212 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -75717,7 +78437,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 === 213 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -75757,7 +78477,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); + (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -75780,25 +78500,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226 /* ModuleDeclaration */: + case 230 /* 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 210 /* WhileStatement */: + case 208 /* IfStatement */: + case 212 /* 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 211 /* ForStatement */: + case 213 /* 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 === 224 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -75823,23 +78543,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 !== 198 /* 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 === 174 /* 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 !== 173 /* ArrayBindingPattern */ && node.kind !== 172 /* ObjectBindingPattern */); + var elements = node.kind === 175 /* 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 !== 198 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -75847,18 +78567,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 === 192 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225 /* EnumDeclaration */: + case 229 /* 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 226 /* 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 232 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -75866,24 +78586,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227 /* ModuleBlock */: + case 231 /* 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 229 /* EnumDeclaration */: + case 226 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 200 /* Block */: + case 204 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 252 /* CatchClause */: + case 256 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -75891,7 +78611,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168 /* ObjectBindingPattern */: + case 172 /* 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); @@ -75907,7 +78627,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169 /* ArrayBindingPattern */: + case 173 /* 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); @@ -75922,12 +78642,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 === 209 /* DoStatement */ || + node.parent.kind === 179 /* CallExpression */ || + node.parent.kind === 180 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 179 /* ParenthesizedExpression */) { + if (node.parent.kind === 183 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -75936,21 +78656,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 210 /* WhileStatement */: + case 209 /* DoStatement */: + case 211 /* ForStatement */: + case 213 /* ForOfStatement */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 183 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -75960,20 +78680,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 === 257 /* 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 === 182 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205 /* DoStatement */) { + if (node.parent.kind === 209 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -75981,7 +78701,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.kind === 213 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -76063,7 +78783,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; }); }; } @@ -76619,8 +79339,15 @@ var ts; return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { + return { + resolvedFileName: undefined, + failedLookupLocations: [] + }; + } return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations }; }); @@ -76706,7 +79433,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.unresolvedImports); }); }; return CoreServicesShimObject; @@ -76789,11 +79516,7 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -/* tslint:disable:no-unused-variable */ // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.1"; -/* tslint:enable:no-unused-variable */ - -//# sourceMappingURL=typescriptServices.js.map +var toolsVersion = "2.2"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 2558f2a3f99..bbf7b441de3 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -163,170 +163,177 @@ 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, + MappedType = 170, + LiteralType = 171, + ObjectBindingPattern = 172, + ArrayBindingPattern = 173, + BindingElement = 174, + ArrayLiteralExpression = 175, + ObjectLiteralExpression = 176, + PropertyAccessExpression = 177, + ElementAccessExpression = 178, + CallExpression = 179, + NewExpression = 180, + TaggedTemplateExpression = 181, + TypeAssertionExpression = 182, + ParenthesizedExpression = 183, + FunctionExpression = 184, + ArrowFunction = 185, + DeleteExpression = 186, + TypeOfExpression = 187, + VoidExpression = 188, + AwaitExpression = 189, + PrefixUnaryExpression = 190, + PostfixUnaryExpression = 191, + BinaryExpression = 192, + ConditionalExpression = 193, + TemplateExpression = 194, + YieldExpression = 195, + SpreadElement = 196, + ClassExpression = 197, + OmittedExpression = 198, + ExpressionWithTypeArguments = 199, + AsExpression = 200, + NonNullExpression = 201, + TemplateSpan = 202, + SemicolonClassElement = 203, + Block = 204, + VariableStatement = 205, + EmptyStatement = 206, + ExpressionStatement = 207, + IfStatement = 208, + DoStatement = 209, + WhileStatement = 210, + ForStatement = 211, + ForInStatement = 212, + ForOfStatement = 213, + ContinueStatement = 214, + BreakStatement = 215, + ReturnStatement = 216, + WithStatement = 217, + SwitchStatement = 218, + LabeledStatement = 219, + ThrowStatement = 220, + TryStatement = 221, + DebuggerStatement = 222, + VariableDeclaration = 223, + VariableDeclarationList = 224, + FunctionDeclaration = 225, + ClassDeclaration = 226, + InterfaceDeclaration = 227, + TypeAliasDeclaration = 228, + EnumDeclaration = 229, + ModuleDeclaration = 230, + ModuleBlock = 231, + CaseBlock = 232, + NamespaceExportDeclaration = 233, + ImportEqualsDeclaration = 234, + ImportDeclaration = 235, + ImportClause = 236, + NamespaceImport = 237, + NamedImports = 238, + ImportSpecifier = 239, + ExportAssignment = 240, + ExportDeclaration = 241, + NamedExports = 242, + ExportSpecifier = 243, + MissingDeclaration = 244, + ExternalModuleReference = 245, + JsxElement = 246, + JsxSelfClosingElement = 247, + JsxOpeningElement = 248, + JsxClosingElement = 249, + JsxAttribute = 250, + JsxSpreadAttribute = 251, + JsxExpression = 252, + CaseClause = 253, + DefaultClause = 254, + HeritageClause = 255, + CatchClause = 256, + PropertyAssignment = 257, + ShorthandPropertyAssignment = 258, + SpreadAssignment = 259, + EnumMember = 260, + SourceFile = 261, + JSDocTypeExpression = 262, + JSDocAllType = 263, + JSDocUnknownType = 264, + JSDocArrayType = 265, + JSDocUnionType = 266, + JSDocTupleType = 267, + JSDocNullableType = 268, + JSDocNonNullableType = 269, + JSDocRecordType = 270, + JSDocRecordMember = 271, + JSDocTypeReference = 272, + JSDocOptionalType = 273, + JSDocFunctionType = 274, + JSDocVariadicType = 275, + JSDocConstructorType = 276, + JSDocThisType = 277, + JSDocComment = 278, + JSDocTag = 279, + JSDocParameterTag = 280, + JSDocReturnTag = 281, + JSDocTypeTag = 282, + JSDocTemplateTag = 283, + JSDocTypedefTag = 284, + JSDocPropertyTag = 285, + JSDocTypeLiteral = 286, + JSDocLiteralType = 287, + JSDocNullKeyword = 288, + JSDocUndefinedKeyword = 289, + JSDocNeverKeyword = 290, + SyntaxList = 291, + NotEmittedStatement = 292, + PartiallyEmittedExpression = 293, + MergeDeclarationMarker = 294, + EndOfDeclarationMarker = 295, + Count = 296, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -334,15 +341,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 = 171, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 139, + LastToken = 140, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -351,11 +358,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 140, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + FirstNode = 141, + FirstJSDocNode = 262, + LastJSDocNode = 287, + FirstJSDocTagNode = 278, + LastJSDocTagNode = 290, } enum NodeFlags { None = 0, @@ -373,21 +380,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 +415,7 @@ declare namespace ts { ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, + ExportDefault = 513, } enum JsxFlags { None = 0, @@ -437,12 +446,14 @@ declare namespace ts { type EqualsGreaterThanToken = Token; type EndOfFileToken = Token; type AtToken = Token; + type ReadonlyToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; + isInJSDocNamespace?: boolean; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; @@ -533,7 +544,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; @@ -547,6 +558,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; @@ -677,6 +692,23 @@ 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 MappedTypeNode extends TypeNode, Declaration { + kind: SyntaxKind.MappedType; + readonlyToken?: ReadonlyToken; + typeParameter: TypeParameterDeclaration; + questionToken?: QuestionToken; + type?: TypeNode; + } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: Expression; @@ -709,9 +741,6 @@ declare namespace ts { operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } @@ -780,6 +809,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; @@ -846,8 +886,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; } /** @@ -1141,12 +1181,16 @@ declare namespace ts { interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; name: Identifier | LiteralExpression; - body?: ModuleBlock | NamespaceDeclaration; + body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; } interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: ModuleBlock | NamespaceDeclaration; } + interface JSDocNamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: JSDocNamespaceDeclaration | Identifier; + } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; statements: NodeArray; @@ -1318,6 +1362,7 @@ declare namespace ts { } interface JSDocTypedefTag extends JSDocTag, Declaration { kind: SyntaxKind.JSDocTypedefTag; + fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression; jsDocTypeLiteral?: JSDocTypeLiteral; @@ -1708,14 +1753,11 @@ declare namespace ts { Null = 4096, Never = 8192, TypeParameter = 16384, - Class = 32768, - Interface = 65536, - Reference = 131072, - Tuple = 262144, - Union = 524288, - Intersection = 1048576, - Anonymous = 2097152, - Instantiated = 4194304, + Object = 32768, + Union = 65536, + Intersection = 131072, + Index = 262144, + IndexedAccess = 524288, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1723,12 +1765,11 @@ declare namespace ts { NumberLike = 340, BooleanLike = 136, EnumLike = 272, - ObjectType = 2588672, - UnionOrIntersection = 1572864, - StructuredType = 4161536, - StructuredOrTypeParameter = 4177920, - Narrowable = 4178943, - NotUnionOrUnit = 2589185, + UnionOrIntersection = 196608, + StructuredType = 229376, + StructuredOrTypeParameter = 507904, + Narrowable = 1033215, + NotUnionOrUnit = 33281, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1749,8 +1790,21 @@ declare namespace ts { interface EnumLiteralType extends LiteralType { baseType: EnumType & UnionType; } + enum ObjectFlags { + Class = 1, + Interface = 2, + Reference = 4, + Tuple = 8, + Anonymous = 16, + Mapped = 32, + Instantiated = 64, + ObjectLiteral = 128, + EvolvingArray = 256, + ObjectLiteralPatternWithComputedProperties = 512, + ClassOrInterface = 3, + } interface ObjectType extends Type { - isObjectLiteralPatternWithComputedProperties?: boolean; + objectFlags: ObjectFlags; } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; @@ -1778,9 +1832,21 @@ declare namespace ts { } interface IntersectionType extends UnionOrIntersectionType { } + type StructuredType = ObjectType | UnionType | IntersectionType; + interface EvolvingArrayType extends ObjectType { + elementType: Type; + finalArrayType?: Type; + } 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, @@ -1882,6 +1948,7 @@ declare namespace ts { preserveConstEnums?: boolean; project?: string; reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -1912,6 +1979,7 @@ declare namespace ts { packageNameToTypingLocation: Map; typingOptions: TypingOptions; compilerOptions: CompilerOptions; + unresolvedImports: ReadonlyArray; } enum ModuleKind { None = 0, @@ -1947,12 +2015,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; @@ -1979,12 +2049,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 { @@ -2042,7 +2145,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; @@ -2057,6 +2164,8 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; + setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout?(timeoutId: any): void; } interface FileWatcher { close(): void; @@ -2159,6 +2268,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; } @@ -2172,7 +2282,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. @@ -2188,7 +2298,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.1.0"; + const version = "2.2.0"; 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 dad603b624a..a36522ece49 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,198 @@ 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["MappedType"] = 170] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 171] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 172] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 173] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 174] = "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"] = 175] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 176] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 177] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 178] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 179] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 180] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 181] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 182] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 183] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 184] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 185] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 186] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 187] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 188] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 189] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 190] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 191] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 192] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 193] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 194] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 195] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 196] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 197] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 198] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 199] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 200] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 201] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 202] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 203] = "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"] = 204] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 205] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 206] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 207] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 208] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 209] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 210] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 211] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 212] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 213] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 214] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 215] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 216] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 217] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 218] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 219] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 220] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 221] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 222] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 223] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 224] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 225] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 226] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 227] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 228] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 229] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 230] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 231] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 232] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 233] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 234] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 235] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 236] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 237] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 238] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 239] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 240] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 241] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 242] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 243] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 244] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "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"] = 246] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 247] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 248] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 249] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 250] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 251] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 252] = "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"] = 253] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 254] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 255] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 256] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 257] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 258] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 259] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 260] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 261] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 262] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 263] = "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"] = 264] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 265] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 266] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 267] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 268] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 269] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 270] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 271] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 272] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 273] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 274] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 275] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 276] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 277] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 278] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 279] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 280] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 281] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 282] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 283] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 284] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 285] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 287] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 288] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 289] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 290] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 291] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 292] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 293] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 294] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 295] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 296] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -353,15 +361,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"] = 171] = "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 +378,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"] = 262] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 287] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 278] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 290] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; NodeFlags[NodeFlags["Let"] = 1] = "Let"; @@ -393,25 +401,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 +440,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 +450,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 +482,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 +490,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 +500,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 +515,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 +528,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 +568,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 +644,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 +668,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"; @@ -670,24 +686,19 @@ var ts; TypeFlags[TypeFlags["Null"] = 4096] = "Null"; TypeFlags[TypeFlags["Never"] = 8192] = "Never"; TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 32768] = "Class"; - TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 524288] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + 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["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; - /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -703,31 +714,44 @@ var ts; TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; + 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"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "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"; + ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference"; + ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple"; + ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous"; + ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped"; + ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated"; + ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; + ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; + ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + })(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 @@ -738,19 +762,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"; @@ -758,53 +782,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"; @@ -931,9 +956,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 @@ -942,61 +976,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"; @@ -1025,16 +1064,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; @@ -1144,12 +1184,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; @@ -1221,12 +1261,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. @@ -1244,6 +1284,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. @@ -1536,20 +1583,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); } @@ -1573,6 +1625,41 @@ var ts; return result; } ts.deduplicate = deduplicate; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function changesAffectModuleResolution(oldOptions, newOptions) { + return !oldOptions || + (oldOptions.module !== newOptions.module) || + (oldOptions.moduleResolution !== newOptions.moduleResolution) || + (oldOptions.noResolve !== newOptions.noResolve) || + (oldOptions.target !== newOptions.target) || + (oldOptions.noLib !== newOptions.noLib) || + (oldOptions.jsx !== newOptions.jsx) || + (oldOptions.allowJs !== newOptions.allowJs) || + (oldOptions.rootDir !== newOptions.rootDir) || + (oldOptions.configFilePath !== newOptions.configFilePath) || + (oldOptions.baseUrl !== newOptions.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) || + !arrayIsEqualTo(oldOptions.lib, newOptions.lib) || + !arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) || + !equalOwnProperties(oldOptions.paths, newOptions.paths); + } + ts.changesAffectModuleResolution = changesAffectModuleResolution; /** * Compacts an array, removing any falsey elements. */ @@ -1594,6 +1681,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++) { @@ -1603,15 +1715,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) { @@ -1624,26 +1760,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 @@ -1651,6 +1778,31 @@ 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; + return result; + } + ts.replaceElement = replaceElement; /** * Performs a binary search, finding the index at which 'value' occurs in 'array'. * If no such index is found, returns the 2's-complement of first index at which @@ -1658,11 +1810,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 @@ -1978,6 +2130,14 @@ var ts; return Array.isArray ? Array.isArray(value) : value instanceof Array; } ts.isArray = isArray; + /** Does nothing. */ + function noop() { } + ts.noop = noop; + /** Throws an error because a function is not implemented. */ + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; function memoize(callback) { var value; return function () { @@ -2094,6 +2254,17 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText + }; + } + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; function chainDiagnosticMessages(details, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -2541,6 +2712,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); } @@ -2581,73 +2756,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); } @@ -2721,29 +2916,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` @@ -2808,14 +3009,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])) { @@ -2874,10 +3075,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); } @@ -2912,13 +3109,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 */; @@ -3055,6 +3252,41 @@ 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) { + var ext = tryGetExtensionFromPath(path); + if (ext !== undefined) { + return ext; + } + Debug.fail("File " + path + " has unknown extension."); + } + ts.extensionFromPath = extensionFromPath; + function tryGetExtensionFromPath(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; + } + } + ts.tryGetExtensionFromPath = tryGetExtensionFromPath; })(ts || (ts = {})); /// var ts; @@ -3376,6 +3608,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, @@ -3385,7 +3618,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 { @@ -3393,7 +3626,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); } }; @@ -3410,7 +3643,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 }; @@ -3491,7 +3724,9 @@ var ts; } catch (e) { } - } + }, + setTimeout: setTimeout, + clearTimeout: clearTimeout }; return nodeSystem; } @@ -3617,7 +3852,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." }, @@ -3727,7 +3962,6 @@ var ts; Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, @@ -3845,14 +4079,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}'" }, @@ -3892,7 +4126,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" }, @@ -3930,8 +4164,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." }, @@ -3943,7 +4175,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." }, @@ -3965,9 +4197,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." }, @@ -4014,6 +4244,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." }, @@ -4037,6 +4274,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." }, @@ -4068,6 +4306,10 @@ 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." }, + An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, 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}'." }, @@ -4167,6 +4409,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." }, @@ -4250,7 +4493,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." }, @@ -4287,11 +4530,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." }, @@ -4300,7 +4548,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." }, @@ -4347,6 +4596,8 @@ var ts; Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, @@ -4354,6 +4605,8 @@ var ts; Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, 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 = {})); /// @@ -4389,7 +4642,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 */, @@ -4399,34 +4652,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 */, @@ -4434,7 +4688,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 139 /* OfKeyword */, + "of": 140 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -5984,10 +6238,13 @@ var ts; case 44 /* comma */: pos++; return token = 25 /* CommaToken */; + case 46 /* dot */: + 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 */; @@ -6112,11 +6369,11 @@ var ts; // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, + increaseIndent: ts.noop, + decreaseIndent: ts.noop, clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; } return stringWriters.pop(); @@ -6131,22 +6388,6 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; - } - ts.arrayIsEqualTo = arrayIsEqualTo; function hasResolvedModule(sourceFile, moduleNameText) { return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); } @@ -6171,7 +6412,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 */ @@ -6200,28 +6443,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 !== 261 /* SourceFile */) { node = node.parent; } return node; @@ -6229,11 +6472,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 204 /* Block */: + case 232 /* CaseBlock */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: return true; } return false; @@ -6324,18 +6567,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 === 291 /* 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 >= 262 /* FirstJSDocNode */ && node.kind <= 287 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 /* FirstJSDocTagNode */ && node.kind <= 285 /* LastJSDocTagNode */; + return node.kind >= 278 /* FirstJSDocTagNode */ && node.kind <= 290 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6434,25 +6677,31 @@ var ts; ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || - isCatchClauseVariableDeclaration(declaration); + isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isCatchClauseVariableDeclarationOrBindingElement(declaration) { + var node = getRootDeclaration(declaration); + return node.kind === 223 /* VariableDeclaration */ && node.parent.kind === 256 /* CatchClause */; + } + ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 /* ModuleDeclaration */ && + return node && node.kind === 230 /* 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 === 230 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 /* SourceFile */ || - node.kind === 226 /* ModuleDeclaration */ || + return node.kind === 261 /* SourceFile */ || + node.kind === 230 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6468,9 +6717,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: return ts.isExternalModule(node.parent); - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6478,22 +6727,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 261 /* SourceFile */: + case 232 /* CaseBlock */: + case 256 /* CatchClause */: + case 230 /* ModuleDeclaration */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return true; - case 200 /* Block */: + case 204 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6513,13 +6762,6 @@ var ts; } } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 219 /* VariableDeclaration */ && - declaration.parent && - declaration.parent.kind === 252 /* CatchClause */; - } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. @@ -6527,12 +6769,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 177 /* 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); @@ -6555,7 +6827,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 === 204 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6569,7 +6841,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256 /* SourceFile */: + case 261 /* 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 @@ -6578,23 +6850,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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 229 /* EnumDeclaration */: + case 260 /* EnumMember */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 228 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6617,7 +6889,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 /* EnumDeclaration */ && isConst(node); + return node.kind === 229 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6630,11 +6902,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 179 /* 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 === 207 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6650,10 +6922,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 === 184 /* FunctionExpression */ || + node.kind === 185 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6669,39 +6941,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 <= 171 /* 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 !== 188 /* VoidExpression */; + case 199 /* 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 === 177 /* 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 === 177 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141 /* QualifiedName */: + case 177 /* 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: @@ -6710,38 +6982,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 <= 171 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 195 /* ExpressionWithTypeArguments */: + case 199 /* 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 223 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* 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 182 /* TypeAssertionExpression */: return node === parent_1.type; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6755,23 +7027,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 216 /* 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 232 /* CaseBlock */: + case 204 /* Block */: + case 208 /* IfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 217 /* WithStatement */: + case 218 /* SwitchStatement */: + case 253 /* CaseClause */: + case 254 /* DefaultClause */: + case 219 /* LabeledStatement */: + case 221 /* TryStatement */: + case 256 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -6781,18 +7053,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191 /* YieldExpression */: + case 195 /* 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 229 /* EnumDeclaration */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* 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. @@ -6800,7 +7072,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); @@ -6819,14 +7091,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 174 /* BindingElement */: + case 260 /* EnumMember */: + case 144 /* Parameter */: + case 257 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 258 /* ShorthandPropertyAssignment */: + case 223 /* VariableDeclaration */: return true; } } @@ -6834,11 +7106,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 === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6847,19 +7119,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* 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; @@ -6867,13 +7139,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: return true; } return false; @@ -6881,30 +7153,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 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: return true; - case 215 /* LabeledStatement */: + case 219 /* 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 === 204 /* 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 === 176 /* 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 === 176 /* ObjectLiteralExpression */ || + node.parent.kind === 197 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6940,7 +7212,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 @@ -6955,9 +7227,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; @@ -6968,26 +7240,26 @@ var ts; node = node.parent; } break; - case 181 /* ArrowFunction */: + case 185 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 230 /* 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 229 /* EnumDeclaration */: + case 261 /* SourceFile */: return node; } } @@ -7008,26 +7280,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* 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; @@ -7043,14 +7315,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { + if (func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 179 /* ParenthesizedExpression */) { + while (parent_2.kind === 183 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 179 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7061,32 +7333,32 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + return (kind === 177 /* PropertyAccessExpression */ || kind === 178 /* 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 272 /* JSDocTypeReference */: + return node.typeName; + case 199 /* 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 179 /* CallExpression */: + case 180 /* NewExpression */: + case 181 /* TaggedTemplateExpression */: + case 145 /* Decorator */: return true; default: return false; @@ -7094,7 +7366,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 181 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7103,25 +7375,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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 === 226 /* 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 === 226 /* 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 === 226 /* ClassDeclaration */; } return false; } @@ -7137,19 +7409,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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 === 248 /* JsxOpeningElement */ || + parent.kind === 247 /* JsxSelfClosingElement */ || + parent.kind === 249 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7163,43 +7435,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 175 /* ArrayLiteralExpression */: + case 176 /* ObjectLiteralExpression */: + case 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 181 /* TaggedTemplateExpression */: + case 200 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 201 /* NonNullExpression */: + case 183 /* ParenthesizedExpression */: + case 184 /* FunctionExpression */: + case 197 /* ClassExpression */: + case 185 /* ArrowFunction */: + case 188 /* VoidExpression */: + case 186 /* DeleteExpression */: + case 187 /* TypeOfExpression */: + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: + case 192 /* BinaryExpression */: + case 193 /* ConditionalExpression */: + case 196 /* SpreadElement */: + case 194 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* OmittedExpression */: - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 191 /* YieldExpression */: - case 185 /* AwaitExpression */: + case 198 /* OmittedExpression */: + case 246 /* JsxElement */: + case 247 /* JsxSelfClosingElement */: + case 195 /* YieldExpression */: + case 189 /* 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 @@ -7208,47 +7480,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 223 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 260 /* EnumMember */: + case 257 /* PropertyAssignment */: + case 174 /* 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 207 /* ExpressionStatement */: + case 208 /* IfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 216 /* ReturnStatement */: + case 217 /* WithStatement */: + case 218 /* SwitchStatement */: + case 253 /* CaseClause */: + case 220 /* ThrowStatement */: + case 218 /* SwitchStatement */: return parent_3.expression === node; - case 207 /* ForStatement */: + case 211 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 224 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 224 /* VariableDeclarationList */) || forInStatement.expression === node; - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: return node === parent_3.expression; - case 198 /* TemplateSpan */: + case 202 /* 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 252 /* JsxExpression */: + case 251 /* JsxSpreadAttribute */: return true; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7266,7 +7538,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; + return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7275,7 +7547,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; + return node.kind === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 245 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7283,7 +7555,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576 /* JavaScriptFile */); + return node && !!(node.flags & 2097152 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** @@ -7293,7 +7565,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 175 /* CallExpression */ && + var isRequire = expression.kind === 179 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7309,9 +7581,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 === 223 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 184 /* FunctionExpression */; } return false; } @@ -7322,11 +7594,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 188 /* BinaryExpression */) { + if (expression.kind !== 192 /* 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 !== 177 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7344,7 +7616,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 === 177 /* 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 */) { @@ -7362,35 +7634,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 235 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 234 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 241 /* ExternalModuleReference */) { + if (reference.kind === 245 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 237 /* ExportDeclaration */) { + if (node.kind === 241 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 230 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 234 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 237 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 /* ImportDeclaration */ + return node.kind === 235 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7398,13 +7670,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 258 /* ShorthandPropertyAssignment */: + case 257 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7412,9 +7684,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 /* JSDocFunctionType */ && + return node.kind === 274 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 271 /* JSDocConstructorType */; + node.parameters[0].type.kind === 276 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -7474,34 +7746,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 === 205 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201 /* VariableStatement */; + node.parent.parent.kind === 205 /* 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 === 230 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 230 /* 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 === 192 /* BinaryExpression */ && parent_4.operatorToken.kind === 57 /* EqualsToken */ && - parent_4.parent.kind === 203 /* ExpressionStatement */; + parent_4.parent.kind === 207 /* 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 === 257 /* 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)); @@ -7527,14 +7799,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 === 280 /* 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 === 280 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { return paramTags; } @@ -7546,15 +7818,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 282 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); + return getJSDocTag(node, 281 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 283 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -7568,7 +7840,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 === 280 /* JSDocParameterTag */) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -7588,13 +7860,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 === 275 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 275 /* JSDocVariadicType */; } } return isDeclaredRestParam(node); @@ -7604,29 +7876,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 192 /* BinaryExpression */: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + 0 /* None */; + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: + var unaryOperator = parent.operator; + return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; + case 183 /* ParenthesizedExpression */: + case 175 /* ArrayLiteralExpression */: + case 196 /* SpreadElement */: + node = parent; + break; + case 258 /* ShorthandPropertyAssignment */: + if (parent.name !== node) { + return 0 /* None */; + } + // Fall through + case 257 /* 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) { @@ -7640,7 +7936,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 === 261 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7654,7 +7950,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { + if (parent.kind === 239 /* ImportSpecifier */ || parent.kind === 243 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7667,7 +7963,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; @@ -7675,31 +7971,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 260 /* EnumMember */: + case 257 /* PropertyAssignment */: + case 177 /* 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 174 /* BindingElement */: + case 239 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7715,13 +8011,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 === 234 /* ImportEqualsDeclaration */ || + node.kind === 233 /* NamespaceExportDeclaration */ || + node.kind === 236 /* ImportClause */ && !!node.name || + node.kind === 237 /* NamespaceImport */ || + node.kind === 239 /* ImportSpecifier */ || + node.kind === 243 /* ExportSpecifier */ || + node.kind === 240 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7807,7 +8103,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) { @@ -7834,7 +8130,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); } @@ -7849,10 +8145,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; @@ -7891,7 +8187,7 @@ var ts; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: case 114 /* StaticKeyword */: return true; } @@ -7900,11 +8196,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 === 174 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7912,15 +8208,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 === 184 /* FunctionExpression */ + || kind === 225 /* FunctionDeclaration */ + || kind === 185 /* ArrowFunction */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 230 /* ModuleDeclaration */ + || kind === 261 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -7928,13 +8224,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; /** @@ -7974,30 +8270,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 === 180 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176 /* NewExpression */: + case 180 /* 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 190 /* PrefixUnaryExpression */: + case 187 /* TypeOfExpression */: + case 188 /* VoidExpression */: + case 186 /* DeleteExpression */: + case 189 /* AwaitExpression */: + case 193 /* ConditionalExpression */: + case 195 /* YieldExpression */: return 1 /* Right */; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8021,15 +8317,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 === 180 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188 /* BinaryExpression */) { + if (expression.kind === 192 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { + else if (expression.kind === 190 /* PrefixUnaryExpression */ || expression.kind === 191 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8047,36 +8343,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 175 /* ArrayLiteralExpression */: + case 176 /* ObjectLiteralExpression */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 197 /* ClassExpression */: + case 246 /* JsxElement */: + case 247 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 190 /* TemplateExpression */: - case 179 /* ParenthesizedExpression */: - case 194 /* OmittedExpression */: + case 194 /* TemplateExpression */: + case 183 /* ParenthesizedExpression */: + case 198 /* OmittedExpression */: return 19; - case 177 /* TaggedTemplateExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 181 /* TaggedTemplateExpression */: + case 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: return 18; - case 176 /* NewExpression */: + case 180 /* NewExpression */: return hasArguments ? 18 : 17; - case 175 /* CallExpression */: + case 179 /* CallExpression */: return 17; - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return 16; - case 186 /* PrefixUnaryExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 185 /* AwaitExpression */: + case 190 /* PrefixUnaryExpression */: + case 187 /* TypeOfExpression */: + case 188 /* VoidExpression */: + case 186 /* DeleteExpression */: + case 189 /* AwaitExpression */: return 15; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8134,11 +8430,11 @@ var ts; default: return -1; } - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return 4; - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return 2; - case 192 /* SpreadElementExpression */: + case 196 /* SpreadElement */: return 1; default: return -1; @@ -8408,21 +8704,36 @@ 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]; - return ts.filter(sourceFiles, isNonDeclarationFile); + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; + return filterSourceFilesInDirectory(sourceFiles, function (file) { return host.isSourceFileFromExternalLibrary(file); }); + } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); } } ts.getSourceFilesToEmit = getSourceFilesToEmit; + /** Don't call this for `--outFile`, just for `--outDir` or plain emit. */ + function filterSourceFilesInDirectory(sourceFiles, isSourceFileFromExternalLibrary) { + return ts.filter(sourceFiles, function (file) { return shouldEmitInDirectory(file, isSourceFileFromExternalLibrary); }); + } + ts.filterSourceFilesInDirectory = filterSourceFilesInDirectory; function isNonDeclarationFile(sourceFile) { return !isDeclarationFile(sourceFile); } + /** + * Whether a file should be emitted in a non-`--outFile` case. + * Don't emit if source file is a declaration file, or was located under node_modules + */ + function shouldEmitInDirectory(sourceFile, isSourceFileFromExternalLibrary) { + return isNonDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + } function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + return isNonDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); } /** * Iterates over each source file to emit. The source files are expected to have been @@ -8500,11 +8811,10 @@ 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 - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + if (shouldEmitInDirectory(sourceFile, function (file) { return host.isSourceFileFromExternalLibrary(file); })) { onSingleFileEmit(host, sourceFile); } } @@ -8537,7 +8847,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)); }); @@ -8577,7 +8887,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; } }); @@ -8619,10 +8929,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 { @@ -8631,7 +8941,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); @@ -8642,10 +8952,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; } } @@ -8872,7 +9182,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } node.modifierFlagsCache = flags | 536870912 /* HasComputedFlags */; @@ -8891,7 +9201,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 */; } @@ -8908,19 +9218,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 === 199 /* 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 === 176 /* ObjectLiteralExpression */ + || kind === 175 /* ArrayLiteralExpression */; } } return false; @@ -8949,20 +9265,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 177 /* 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 === 177 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172 /* ObjectLiteralExpression */) { + if (kind === 176 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 171 /* ArrayLiteralExpression */) { + if (kind === 175 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9124,39 +9440,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 173 /* PropertyAccessExpression */) { + else if (kind === 177 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174 /* ElementAccessExpression */) { + else if (kind === 178 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 /* PrefixUnaryExpression */ - || kind === 187 /* PostfixUnaryExpression */) { + else if (kind === 190 /* PrefixUnaryExpression */ + || kind === 191 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188 /* BinaryExpression */) { + else if (kind === 192 /* 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 === 193 /* 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 === 188 /* VoidExpression */ + || kind === 187 /* TypeOfExpression */ + || kind === 186 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171 /* ArrayLiteralExpression */) { + else if (kind === 175 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 172 /* ObjectLiteralExpression */) { + else if (kind === 176 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 175 /* CallExpression */) { + else if (kind === 179 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9315,28 +9631,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 235 /* 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 234 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 245 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -9352,22 +9671,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 240 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; + case 205 /* 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 225 /* 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 226 /* 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 229 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -9382,7 +9790,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 === 226 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9459,16 +9867,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; @@ -9477,7 +9885,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) { @@ -9489,60 +9897,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 168 /* ObjectBindingPattern */ - || kind === 169 /* ArrayBindingPattern */; + || kind === 172 /* ObjectBindingPattern */ + || kind === 173 /* 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 === 203 /* 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 === 257 /* PropertyAssignment */ + || kind === 258 /* ShorthandPropertyAssignment */ + || kind === 259 /* SpreadAssignment */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 244 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + return (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* 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 === 199 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9557,95 +9966,103 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 /* ArrayBindingPattern */ - || kind === 168 /* ObjectBindingPattern */; + return kind === 173 /* ArrayBindingPattern */ + || kind === 172 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170 /* BindingElement */; + return node.kind === 174 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 /* BindingElement */ - || kind === 194 /* OmittedExpression */; + return kind === 174 /* BindingElement */ + || kind === 198 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression + function isArrayLiteralExpression(node) { + return node.kind === 175 /* ArrayLiteralExpression */; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 176 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173 /* PropertyAccessExpression */; + return node.kind === 177 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174 /* ElementAccessExpression */; + return node.kind === 178 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188 /* BinaryExpression */; + return node.kind === 192 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189 /* ConditionalExpression */; + return node.kind === 193 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175 /* CallExpression */; + return node.kind === 179 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 /* TemplateExpression */ + return kind === 194 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192 /* SpreadElementExpression */; + function isSpreadExpression(node) { + return node.kind === 196 /* SpreadElement */; } - ts.isSpreadElementExpression = isSpreadElementExpression; + ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 195 /* ExpressionWithTypeArguments */; + return node.kind === 199 /* 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 === 177 /* PropertyAccessExpression */ + || kind === 178 /* ElementAccessExpression */ + || kind === 180 /* NewExpression */ + || kind === 179 /* CallExpression */ + || kind === 246 /* JsxElement */ + || kind === 247 /* JsxSelfClosingElement */ + || kind === 181 /* TaggedTemplateExpression */ + || kind === 175 /* ArrayLiteralExpression */ + || kind === 183 /* ParenthesizedExpression */ + || kind === 176 /* ObjectLiteralExpression */ + || kind === 197 /* ClassExpression */ + || kind === 184 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 190 /* TemplateExpression */ + || kind === 194 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 197 /* NonNullExpression */; + || kind === 201 /* 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 === 190 /* PrefixUnaryExpression */ + || kind === 191 /* PostfixUnaryExpression */ + || kind === 186 /* DeleteExpression */ + || kind === 187 /* TypeOfExpression */ + || kind === 188 /* VoidExpression */ + || kind === 189 /* AwaitExpression */ + || kind === 182 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9653,13 +10070,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 === 193 /* ConditionalExpression */ + || kind === 195 /* YieldExpression */ + || kind === 185 /* ArrowFunction */ + || kind === 192 /* BinaryExpression */ + || kind === 196 /* SpreadElement */ + || kind === 200 /* AsExpression */ + || kind === 198 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9668,16 +10085,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 /* TypeAssertionExpression */ - || kind === 196 /* AsExpression */; + return kind === 182 /* TypeAssertionExpression */ + || kind === 200 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288 /* PartiallyEmittedExpression */; + return node.kind === 293 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287 /* NotEmittedStatement */; + return node.kind === 292 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9686,17 +10103,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194 /* OmittedExpression */; + return node.kind === 198 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 198 /* TemplateSpan */; + return node.kind === 202 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 200 /* Block */; + return node.kind === 204 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9714,119 +10131,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219 /* VariableDeclaration */; + return node.kind === 223 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220 /* VariableDeclarationList */; + return node.kind === 224 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228 /* CaseBlock */; + return node.kind === 232 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 /* ModuleBlock */ - || kind === 226 /* ModuleDeclaration */; + return kind === 231 /* ModuleBlock */ + || kind === 230 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */; + return node.kind === 234 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232 /* ImportClause */; + return node.kind === 236 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 /* NamedImports */ - || kind === 233 /* NamespaceImport */; + return kind === 238 /* NamedImports */ + || kind === 237 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235 /* ImportSpecifier */; + return node.kind === 239 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238 /* NamedExports */; + return node.kind === 242 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239 /* ExportSpecifier */; + return node.kind === 243 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; + return node.kind === 230 /* ModuleDeclaration */ || node.kind === 229 /* 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 === 185 /* ArrowFunction */ + || kind === 174 /* BindingElement */ + || kind === 226 /* ClassDeclaration */ + || kind === 197 /* ClassExpression */ + || kind === 150 /* Constructor */ + || kind === 229 /* EnumDeclaration */ + || kind === 260 /* EnumMember */ + || kind === 243 /* ExportSpecifier */ + || kind === 225 /* FunctionDeclaration */ + || kind === 184 /* FunctionExpression */ + || kind === 151 /* GetAccessor */ + || kind === 236 /* ImportClause */ + || kind === 234 /* ImportEqualsDeclaration */ + || kind === 239 /* ImportSpecifier */ + || kind === 227 /* InterfaceDeclaration */ + || kind === 149 /* MethodDeclaration */ + || kind === 148 /* MethodSignature */ + || kind === 230 /* ModuleDeclaration */ + || kind === 233 /* NamespaceExportDeclaration */ + || kind === 237 /* NamespaceImport */ + || kind === 144 /* Parameter */ + || kind === 257 /* PropertyAssignment */ + || kind === 147 /* PropertyDeclaration */ + || kind === 146 /* PropertySignature */ + || kind === 152 /* SetAccessor */ + || kind === 258 /* ShorthandPropertyAssignment */ + || kind === 228 /* TypeAliasDeclaration */ + || kind === 143 /* TypeParameter */ + || kind === 223 /* VariableDeclaration */ + || kind === 284 /* 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 === 225 /* FunctionDeclaration */ + || kind === 244 /* MissingDeclaration */ + || kind === 226 /* ClassDeclaration */ + || kind === 227 /* InterfaceDeclaration */ + || kind === 228 /* TypeAliasDeclaration */ + || kind === 229 /* EnumDeclaration */ + || kind === 230 /* ModuleDeclaration */ + || kind === 235 /* ImportDeclaration */ + || kind === 234 /* ImportEqualsDeclaration */ + || kind === 241 /* ExportDeclaration */ + || kind === 240 /* ExportAssignment */ + || kind === 233 /* 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 === 215 /* BreakStatement */ + || kind === 214 /* ContinueStatement */ + || kind === 222 /* DebuggerStatement */ + || kind === 209 /* DoStatement */ + || kind === 207 /* ExpressionStatement */ + || kind === 206 /* EmptyStatement */ + || kind === 212 /* ForInStatement */ + || kind === 213 /* ForOfStatement */ + || kind === 211 /* ForStatement */ + || kind === 208 /* IfStatement */ + || kind === 219 /* LabeledStatement */ + || kind === 216 /* ReturnStatement */ + || kind === 218 /* SwitchStatement */ + || kind === 220 /* ThrowStatement */ + || kind === 221 /* TryStatement */ + || kind === 205 /* VariableStatement */ + || kind === 210 /* WhileStatement */ + || kind === 217 /* WithStatement */ + || kind === 292 /* NotEmittedStatement */ + || kind === 295 /* EndOfDeclarationMarker */ + || kind === 294 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -9847,93 +10266,93 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200 /* Block */; + || kind === 204 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 241 /* ExternalModuleReference */ - || kind === 140 /* QualifiedName */ + return kind === 245 /* ExternalModuleReference */ + || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 244 /* JsxOpeningElement */; + return node.kind === 248 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245 /* JsxClosingElement */; + return node.kind === 249 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 173 /* PropertyAccessExpression */; + || kind === 177 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 /* JsxElement */ - || kind === 248 /* JsxExpression */ - || kind === 243 /* JsxSelfClosingElement */ + return kind === 246 /* JsxElement */ + || kind === 252 /* JsxExpression */ + || kind === 247 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 /* JsxAttribute */ - || kind === 247 /* JsxSpreadAttribute */; + return kind === 250 /* JsxAttribute */ + || kind === 251 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247 /* JsxSpreadAttribute */; + return node.kind === 251 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246 /* JsxAttribute */; + return node.kind === 250 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 248 /* JsxExpression */; + || kind === 252 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 /* CaseClause */ - || kind === 250 /* DefaultClause */; + return kind === 253 /* CaseClause */ + || kind === 254 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251 /* HeritageClause */; + return node.kind === 255 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252 /* CatchClause */; + return node.kind === 256 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 253 /* PropertyAssignment */; + return node.kind === 257 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254 /* ShorthandPropertyAssignment */; + return node.kind === 258 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 260 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 256 /* SourceFile */; + return node.kind === 261 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -9945,6 +10364,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 */: @@ -10162,9 +10582,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 === 227 /* InterfaceDeclaration */) { return current; } } @@ -10172,11 +10592,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 === 174 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10184,14 +10604,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 223 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 224 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 205 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10207,14 +10627,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 223 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 224 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 205 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10229,7 +10649,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 /* SourceFile */ + var ConstructorForKind = kind === 261 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -10412,7 +10832,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; } @@ -10425,17 +10845,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; @@ -10445,17 +10856,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; @@ -10473,7 +10884,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; @@ -10493,7 +10904,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; @@ -10511,7 +10922,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; @@ -10530,7 +10941,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; @@ -10549,7 +10960,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(168 /* ObjectBindingPattern */, location); + var node = createNode(172 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10562,7 +10973,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169 /* ArrayBindingPattern */, location); + var node = createNode(173 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10575,7 +10986,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170 /* BindingElement */, location); + var node = createNode(174 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10592,7 +11003,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171 /* ArrayLiteralExpression */, location); + var node = createNode(175 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10608,7 +11019,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172 /* ObjectLiteralExpression */, location); + var node = createNode(176 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10624,7 +11035,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173 /* PropertyAccessExpression */, location, flags); + var node = createNode(177 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10642,7 +11053,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174 /* ElementAccessExpression */, location); + var node = createNode(178 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10656,7 +11067,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* CallExpression */, location, flags); + var node = createNode(179 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10673,7 +11084,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176 /* NewExpression */, location, flags); + var node = createNode(180 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10688,7 +11099,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177 /* TaggedTemplateExpression */, location); + var node = createNode(181 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10702,7 +11113,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179 /* ParenthesizedExpression */, location); + var node = createNode(183 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10715,7 +11126,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(184 /* FunctionExpression */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10734,7 +11145,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(185 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10752,7 +11163,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182 /* DeleteExpression */, location); + var node = createNode(186 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10765,7 +11176,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183 /* TypeOfExpression */, location); + var node = createNode(187 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10778,7 +11189,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184 /* VoidExpression */, location); + var node = createNode(188 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10791,7 +11202,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185 /* AwaitExpression */, location); + var node = createNode(189 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10804,7 +11215,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186 /* PrefixUnaryExpression */, location); + var node = createNode(190 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10818,7 +11229,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187 /* PostfixUnaryExpression */, location); + var node = createNode(191 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10834,7 +11245,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(192 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10849,7 +11260,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189 /* ConditionalExpression */, location); + var node = createNode(193 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10866,7 +11277,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190 /* TemplateExpression */, location); + var node = createNode(194 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10880,7 +11291,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191 /* YieldExpression */, location); + var node = createNode(195 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10894,7 +11305,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192 /* SpreadElementExpression */, location); + var node = createNode(196 /* SpreadElement */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10907,7 +11318,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193 /* ClassExpression */, location); + var node = createNode(197 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10925,12 +11336,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194 /* OmittedExpression */, location); + var node = createNode(198 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195 /* ExpressionWithTypeArguments */, location); + var node = createNode(199 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10945,7 +11356,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(198 /* TemplateSpan */, location); + var node = createNode(202 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -10960,7 +11371,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(200 /* Block */, location, flags); + var block = createNode(204 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10976,7 +11387,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201 /* VariableStatement */, location, flags); + var node = createNode(205 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10991,7 +11402,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220 /* VariableDeclarationList */, location, flags); + var node = createNode(224 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11004,7 +11415,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219 /* VariableDeclaration */, location, flags); + var node = createNode(223 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11019,11 +11430,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202 /* EmptyStatement */, location); + return createNode(206 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203 /* ExpressionStatement */, location, flags); + var node = createNode(207 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11036,7 +11447,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204 /* IfStatement */, location); + var node = createNode(208 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11051,7 +11462,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205 /* DoStatement */, location); + var node = createNode(209 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11065,7 +11476,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206 /* WhileStatement */, location); + var node = createNode(210 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11079,7 +11490,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(211 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11095,7 +11506,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208 /* ForInStatement */, location); + var node = createNode(212 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11110,7 +11521,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209 /* ForOfStatement */, location); + var node = createNode(213 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11125,7 +11536,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210 /* ContinueStatement */, location); + var node = createNode(214 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11140,7 +11551,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211 /* BreakStatement */, location); + var node = createNode(215 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11155,7 +11566,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212 /* ReturnStatement */, location); + var node = createNode(216 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11168,7 +11579,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213 /* WithStatement */, location); + var node = createNode(217 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11182,7 +11593,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214 /* SwitchStatement */, location); + var node = createNode(218 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11196,7 +11607,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215 /* LabeledStatement */, location); + var node = createNode(219 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11210,7 +11621,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216 /* ThrowStatement */, location); + var node = createNode(220 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11223,7 +11634,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217 /* TryStatement */, location); + var node = createNode(221 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11238,7 +11649,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228 /* CaseBlock */, location); + var node = createNode(232 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11251,7 +11662,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(225 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11271,7 +11682,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222 /* ClassDeclaration */, location); + var node = createNode(226 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11289,7 +11700,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231 /* ImportDeclaration */, location); + var node = createNode(235 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11305,7 +11716,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232 /* ImportClause */, location); + var node = createNode(236 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11319,7 +11730,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233 /* NamespaceImport */, location); + var node = createNode(237 /* NamespaceImport */, location); node.name = name; return node; } @@ -11332,7 +11743,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234 /* NamedImports */, location); + var node = createNode(238 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11345,7 +11756,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235 /* ImportSpecifier */, location); + var node = createNode(239 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11359,7 +11770,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236 /* ExportAssignment */, location); + var node = createNode(240 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11375,7 +11786,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237 /* ExportDeclaration */, location); + var node = createNode(241 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11391,7 +11802,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238 /* NamedExports */, location); + var node = createNode(242 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11404,7 +11815,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239 /* ExportSpecifier */, location); + var node = createNode(243 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11419,7 +11830,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242 /* JsxElement */, location); + var node = createNode(246 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11434,7 +11845,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243 /* JsxSelfClosingElement */, location); + var node = createNode(247 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11448,7 +11859,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244 /* JsxOpeningElement */, location); + var node = createNode(248 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11462,7 +11873,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245 /* JsxClosingElement */, location); + var node = createNode(249 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11475,7 +11886,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246 /* JsxAttribute */, location); + var node = createNode(250 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11489,7 +11900,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247 /* JsxSpreadAttribute */, location); + var node = createNode(251 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11502,7 +11913,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248 /* JsxExpression */, location); + var node = createNode(252 /* JsxExpression */, location); node.expression = expression; return node; } @@ -11516,7 +11927,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(251 /* HeritageClause */, location); + var node = createNode(255 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11530,7 +11941,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249 /* CaseClause */, location); + var node = createNode(253 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11544,7 +11955,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250 /* DefaultClause */, location); + var node = createNode(254 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11557,7 +11968,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252 /* CatchClause */, location); + var node = createNode(256 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11572,7 +11983,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(253 /* PropertyAssignment */, location); + var node = createNode(257 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11587,12 +11998,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254 /* ShorthandPropertyAssignment */, location); + var node = createNode(258 /* 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(259 /* 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); @@ -11600,10 +12017,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(261 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11672,11 +12096,33 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(287 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(292 /* 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(295 /* 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(294 /* 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. @@ -11686,7 +12132,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(293 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -11759,15 +12205,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, [ @@ -11807,10 +12244,25 @@ var ts; // flag and setting a parent node. var react = createIdentifier(reactNamespace || "React"); react.flags &= ~8 /* Synthesized */; - react.parent = parent; + // Set the parent that is in parse tree + // this makes sure that parent chain is intact for checker to traverse complete scope tree + 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); @@ -11830,10 +12282,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 */); } @@ -11922,20 +12386,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) { @@ -11960,7 +12422,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"), @@ -11970,9 +12432,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 ])))))); @@ -11988,8 +12449,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, @@ -12019,13 +12480,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12045,7 +12506,7 @@ var ts; } else { switch (callee.kind) { - case 173 /* PropertyAccessExpression */: { + case 177 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12059,7 +12520,7 @@ var ts; } break; } - case 174 /* ElementAccessExpression */: { + case 178 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12113,14 +12574,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 257 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12184,6 +12645,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"; @@ -12273,7 +12840,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 === 183 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12307,8 +12874,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(192 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(192 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12317,7 +12884,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 === 195 /* YieldExpression */) { return false; } return true; @@ -12405,7 +12972,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12428,9 +12995,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175 /* CallExpression */: + case 179 /* CallExpression */: return createParen(expression); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12455,7 +13022,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 180 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12493,7 +13060,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(192 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12504,7 +13071,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 === 184 /* FunctionExpression */ || kind === 185 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12512,7 +13079,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { + if (leftmostExpressionKind === 176 /* ObjectLiteralExpression */ || leftmostExpressionKind === 184 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12536,21 +13103,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: node = node.operand; continue; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: node = node.left; continue; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: node = node.condition; continue; - case 175 /* CallExpression */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 179 /* CallExpression */: + case 178 /* ElementAccessExpression */: + case 177 /* PropertyAccessExpression */: node = node.expression; continue; - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -12559,19 +13126,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 176 /* 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; @@ -12591,7 +13158,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */) { + while (node.kind === 183 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12605,7 +13172,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288 /* PartiallyEmittedExpression */) { + while (node.kind === 293 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -12680,7 +13247,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 === 261 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12822,13 +13389,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 === 235 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 241 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12885,6 +13452,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 === 185 /* 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 !== 185 /* 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 = {})); /// /// @@ -12896,13 +13820,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256 /* SourceFile */) { + if (kind === 261 /* 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 { @@ -12945,26 +13869,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 258 /* 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 259 /* SpreadAssignment */: + return visitNode(cbNode, node.expression); + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 257 /* PropertyAssignment */: + case 223 /* VariableDeclaration */: + case 174 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12973,24 +13899,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13001,308 +13927,318 @@ 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 /* MappedType */: + return visitNode(cbNode, node.readonlyToken) || + visitNode(cbNode, node.typeParameter) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type); + case 171 /* LiteralType */: return visitNode(cbNode, node.literal); - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178 /* TypeAssertionExpression */: + case 182 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196 /* AsExpression */: + case 200 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 189 /* ConditionalExpression */: + case 193 /* 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 196 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 204 /* Block */: + case 231 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 256 /* SourceFile */: + case 261 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 214 /* ContinueStatement */: + case 215 /* BreakStatement */: return visitNode(cbNode, node.label); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 249 /* CaseClause */: + case 253 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252 /* CatchClause */: + case 256 /* 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 226 /* ClassDeclaration */: + case 197 /* 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 227 /* 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 228 /* 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 229 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255 /* EnumMember */: + case 260 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229 /* NamespaceExportDeclaration */: + case 233 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 237 /* ExportDeclaration */: + case 241 /* 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 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198 /* TemplateSpan */: + case 202 /* 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 255 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241 /* ExternalModuleReference */: + case 245 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 240 /* MissingDeclaration */: + case 244 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 242 /* JsxElement */: + case 246 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 247 /* JsxSelfClosingElement */: + case 248 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 257 /* JSDocTypeExpression */: + case 262 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 261 /* JSDocUnionType */: + case 266 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 262 /* JSDocTupleType */: + case 267 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 260 /* JSDocArrayType */: + case 265 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 264 /* JSDocNonNullableType */: + case 269 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 263 /* JSDocNullableType */: + case 268 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 265 /* JSDocRecordType */: + case 270 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 267 /* JSDocTypeReference */: + case 272 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 268 /* JSDocOptionalType */: + case 273 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 269 /* JSDocFunctionType */: + case 274 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 270 /* JSDocVariadicType */: + case 275 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 271 /* JSDocConstructorType */: + case 276 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 272 /* JSDocThisType */: + case 277 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 266 /* JSDocRecordMember */: + case 271 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273 /* JSDocComment */: + case 278 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 275 /* JSDocParameterTag */: + case 280 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276 /* JSDocReturnTag */: + case 281 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 277 /* JSDocTypeTag */: + case 282 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 278 /* JSDocTemplateTag */: + case 283 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281 /* JSDocTypeLiteral */: + case 286 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280 /* JSDocPropertyTag */: + case 285 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 282 /* JSDocLiteralType */: + case 287 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -13316,6 +14252,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; } @@ -13357,8 +14297,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; @@ -13456,6 +14396,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 */; @@ -13472,7 +14422,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); @@ -13560,7 +14510,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(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13580,16 +14530,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 @@ -13630,40 +14580,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(); @@ -13844,7 +14794,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); } @@ -13867,7 +14817,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; } @@ -13936,7 +14886,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 @@ -14023,9 +14973,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. @@ -14045,29 +14997,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'."); @@ -14120,7 +15072,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 */; @@ -14128,35 +15080,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 */; } } @@ -14183,7 +15136,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; @@ -14258,7 +15211,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; } @@ -14293,20 +15246,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 @@ -14314,7 +15269,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. @@ -14338,14 +15293,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 203 /* 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. @@ -14360,8 +15315,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 253 /* CaseClause */: + case 254 /* DefaultClause */: return true; } } @@ -14370,58 +15325,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 225 /* FunctionDeclaration */: + case 205 /* VariableStatement */: + case 204 /* Block */: + case 208 /* IfStatement */: + case 207 /* ExpressionStatement */: + case 220 /* ThrowStatement */: + case 216 /* ReturnStatement */: + case 218 /* SwitchStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 211 /* ForStatement */: + case 210 /* WhileStatement */: + case 217 /* WithStatement */: + case 206 /* EmptyStatement */: + case 221 /* TryStatement */: + case 219 /* LabeledStatement */: + case 209 /* DoStatement */: + case 222 /* DebuggerStatement */: + case 235 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 241 /* ExportDeclaration */: + case 240 /* ExportAssignment */: + case 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 228 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 260 /* 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 !== 223 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14442,7 +15397,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. @@ -14464,6 +15419,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; @@ -14475,17 +15431,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; } } ; @@ -14554,7 +15510,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); @@ -14593,7 +15549,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190 /* TemplateExpression */); + var template = createNode(194 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14605,7 +15561,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198 /* TemplateSpan */); + var span = createNode(202 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -14660,33 +15616,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 @@ -14711,7 +15667,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() { @@ -14724,7 +15680,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(); @@ -14823,7 +15779,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); @@ -14887,7 +15843,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 */); @@ -14899,7 +15855,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; @@ -14910,7 +15866,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; @@ -14959,10 +15915,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(); @@ -14976,7 +15932,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); } @@ -14991,13 +15947,40 @@ var ts; } return members; } + function isStartOfMappedType() { + nextToken(); + if (token() === 130 /* ReadonlyKeyword */) { + nextToken(); + } + return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; + } + function parseMappedTypeParameter() { + var node = createNode(143 /* TypeParameter */); + node.name = parseIdentifier(); + parseExpected(91 /* InKeyword */); + node.constraint = parseType(); + return finishNode(node); + } + function parseMappedType() { + var node = createNode(170 /* MappedType */); + parseExpected(16 /* OpenBraceToken */); + node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); + parseExpected(20 /* OpenBracketToken */); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(21 /* CloseBracketToken */); + node.questionToken = parseOptionalToken(54 /* QuestionToken */); + node.type = parseTypeAnnotation(); + parseSemicolon(); + parseExpected(17 /* CloseBraceToken */); + return finishNode(node); + } 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 */); @@ -15005,7 +15988,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); @@ -15016,7 +15999,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167 /* LiteralType */); + var node = createNode(171 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15027,12 +16010,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(); @@ -15058,7 +16041,7 @@ var ts; case 102 /* TypeOfKeyword */: return parseTypeQuery(); case 16 /* OpenBraceToken */: - return parseTypeLiteral(); + return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); case 20 /* OpenBracketToken */: return parseTupleType(); case 18 /* OpenParenToken */: @@ -15070,16 +16053,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 */: @@ -15106,13 +16089,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) { @@ -15128,10 +16134,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 */) { @@ -15188,7 +16194,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); @@ -15207,14 +16213,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(); } @@ -15415,7 +16421,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191 /* YieldExpression */); + var node = createNode(195 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -15437,13 +16443,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(185 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181 /* ArrowFunction */, identifier.pos); + node = createNode(185 /* 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); @@ -15625,7 +16631,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181 /* ArrowFunction */); + var node = createNode(185 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15691,7 +16697,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(193 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15704,7 +16710,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) { @@ -15812,39 +16818,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188 /* BinaryExpression */, left.pos); + var node = createNode(192 /* 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(200 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(190 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182 /* DeleteExpression */); + var node = createNode(186 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183 /* TypeOfExpression */); + var node = createNode(187 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184 /* VoidExpression */); + var node = createNode(188 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15860,7 +16866,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185 /* AwaitExpression */); + var node = createNode(189 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15903,7 +16909,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 === 182 /* 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 { @@ -15999,7 +17005,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(190 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -16012,7 +17018,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(191 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16116,7 +17122,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(177 /* 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); @@ -16141,8 +17147,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 === 248 /* JsxOpeningElement */) { + var node = createNode(246 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16152,7 +17158,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 247 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16167,7 +17173,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(192 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16226,7 +17232,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(248 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -16238,7 +17244,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(243 /* JsxSelfClosingElement */, fullStart); + node = createNode(247 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16254,7 +17260,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16262,7 +17268,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248 /* JsxExpression */); + var node = createNode(252 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -16281,7 +17287,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246 /* JsxAttribute */); + var node = createNode(250 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -16296,7 +17302,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247 /* JsxSpreadAttribute */); + var node = createNode(251 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -16304,7 +17310,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245 /* JsxClosingElement */); + var node = createNode(249 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16317,7 +17323,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178 /* TypeAssertionExpression */); + var node = createNode(182 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -16328,7 +17334,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(177 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16336,14 +17342,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(201 /* 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(178 /* 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. @@ -16359,7 +17365,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(181 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -16382,7 +17388,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(179 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16390,7 +17396,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(179 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16409,7 +17415,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; @@ -16500,28 +17506,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179 /* ParenthesizedExpression */); + var node = createNode(183 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192 /* SpreadElementExpression */); + var node = createNode(196 /* 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(198 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171 /* ArrayLiteralExpression */); + var node = createNode(175 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16532,15 +17538,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(259 /* SpreadAssignment */, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -16562,7 +17574,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(258 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -16573,7 +17585,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(257 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16583,7 +17595,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172 /* ObjectLiteralExpression */); + var node = createNode(176 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16602,7 +17614,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(180 /* FunctionExpression */); + var node = createNode(184 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -16624,7 +17636,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176 /* NewExpression */); + var node = createNode(180 /* NewExpression */); parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -16635,7 +17647,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200 /* Block */); + var node = createNode(204 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16668,12 +17680,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202 /* EmptyStatement */); + var node = createNode(206 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(204 /* IfStatement */); + var node = createNode(208 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16683,7 +17695,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205 /* DoStatement */); + var node = createNode(209 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -16698,7 +17710,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206 /* WhileStatement */); + var node = createNode(210 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16721,21 +17733,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(208 /* ForInStatement */, pos); + var forInStatement = createNode(212 /* 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(213 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207 /* ForStatement */, pos); + var forStatement = createNode(211 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -16753,7 +17765,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 215 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16761,7 +17773,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212 /* ReturnStatement */); + var node = createNode(216 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16770,7 +17782,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213 /* WithStatement */); + var node = createNode(217 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16779,7 +17791,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249 /* CaseClause */); + var node = createNode(253 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -16787,7 +17799,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250 /* DefaultClause */); + var node = createNode(254 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -16797,12 +17809,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214 /* SwitchStatement */); + var node = createNode(218 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(232 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -16817,7 +17829,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(220 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -16825,7 +17837,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(217 /* TryStatement */); + var node = createNode(221 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -16838,7 +17850,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252 /* CatchClause */); + var result = createNode(256 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16848,7 +17860,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218 /* DebuggerStatement */); + var node = createNode(222 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -16860,13 +17872,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(219 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(207 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16916,10 +17928,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 */: @@ -16927,14 +17939,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 */: @@ -16994,17 +18006,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); @@ -17047,9 +18059,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(210 /* ContinueStatement */); + return parseBreakOrContinueStatement(214 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(211 /* BreakStatement */); + return parseBreakOrContinueStatement(215 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -17069,9 +18081,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 */: @@ -17082,8 +18094,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(); } @@ -17106,13 +18118,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); @@ -17131,7 +18143,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(244 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17153,16 +18165,17 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(194 /* OmittedExpression */); + return createNode(198 /* OmittedExpression */); } - var node = createNode(170 /* BindingElement */); + var node = createNode(174 /* 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(174 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { @@ -17177,14 +18190,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168 /* ObjectBindingPattern */); + var node = createNode(172 /* 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(173 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -17203,7 +18216,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219 /* VariableDeclaration */); + var node = createNode(223 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17212,7 +18225,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220 /* VariableDeclarationList */); + var node = createNode(224 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -17235,7 +18248,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 { @@ -17250,7 +18263,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201 /* VariableStatement */, fullStart); + var node = createNode(205 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17258,7 +18271,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221 /* FunctionDeclaration */, fullStart); + var node = createNode(225 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -17271,7 +18284,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 */); @@ -17280,7 +18293,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; @@ -17293,7 +18306,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; @@ -17310,7 +18323,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)); } @@ -17345,7 +18358,7 @@ var ts; case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: return true; default: return false; @@ -17386,7 +18399,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 @@ -17416,7 +18429,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) { @@ -17482,7 +18495,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(199 /* SemicolonClassElement */); + var result = createNode(203 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17510,8 +18523,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."); @@ -17520,10 +18533,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 193 /* ClassExpression */); + /*modifiers*/ undefined, 197 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 226 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17561,13 +18574,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(255 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -17576,10 +18589,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195 /* ExpressionWithTypeArguments */); + var node = createNode(199 /* 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); } @@ -17590,7 +18603,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* InterfaceDeclaration */, fullStart); + var node = createNode(227 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -17601,10 +18614,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* TypeAliasDeclaration */, fullStart); + var node = createNode(228 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135 /* TypeKeyword */); + parseExpected(136 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -17617,13 +18630,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(260 /* 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(229 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -17638,7 +18651,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(231 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -17649,7 +18662,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(230 /* 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 */; @@ -17663,10 +18676,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(230 /* 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 */; @@ -17684,15 +18697,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); } @@ -17700,7 +18713,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 /* RequireKeyword */ && + return token() === 131 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -17710,13 +18723,13 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(233 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); - parseExpected(127 /* NamespaceKeyword */); + parseExpected(128 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); - parseExpected(24 /* SemicolonToken */); + parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { @@ -17725,11 +18738,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(234 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17740,7 +18753,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(235 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -17750,7 +18763,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137 /* FromKeyword */); + parseExpected(138 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17763,7 +18776,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(232 /* ImportClause */, fullStart); + var importClause = createNode(236 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17773,7 +18786,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(238 /* NamedImports */); } return finishNode(importClause); } @@ -17783,8 +18796,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(241 /* ExternalModuleReference */); - parseExpected(130 /* RequireKeyword */); + var node = createNode(245 /* ExternalModuleReference */); + parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(19 /* CloseParenToken */); @@ -17806,7 +18819,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(233 /* NamespaceImport */); + var namespaceImport = createNode(237 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -17821,14 +18834,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 === 238 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239 /* ExportSpecifier */); + return parseImportOrExportSpecifier(243 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235 /* ImportSpecifier */); + return parseImportOrExportSpecifier(239 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17853,27 +18866,27 @@ var ts; else { node.name = identifierName; } - if (kind === 235 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 239 /* 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(241 /* 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(242 /* 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(); } } @@ -17881,7 +18894,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236 /* ExportAssignment */, fullStart); + var node = createNode(240 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -17963,10 +18976,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 === 234 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 245 /* ExternalModuleReference */ + || node.kind === 235 /* ImportDeclaration */ + || node.kind === 240 /* ExportAssignment */ + || node.kind === 241 /* ExportDeclaration */ ? node : undefined; }); @@ -17990,16 +19003,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) { @@ -18027,8 +19041,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(); @@ -18040,7 +19054,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(262 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -18051,12 +19065,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(261 /* JSDocUnionType */, type.pos); + var unionType = createNode(266 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(273 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -18067,20 +19081,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(260 /* JSDocArrayType */, type.pos); + var arrayType = createNode(265 /* 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(268 /* 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(269 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -18114,14 +19128,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 */: @@ -18132,30 +19146,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272 /* JSDocThisType */); + var result = createNode(277 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271 /* JSDocConstructorType */); + var result = createNode(276 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270 /* JSDocVariadicType */); + var result = createNode(275 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269 /* JSDocFunctionType */); + var result = createNode(274 /* 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 */) { @@ -18165,7 +19179,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? @@ -18174,7 +19188,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267 /* JSDocTypeReference */); + var result = createNode(272 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -18195,7 +19209,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 */); @@ -18209,26 +19223,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(270 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264 /* JSDocNonNullableType */); + var result = createNode(269 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262 /* JSDocTupleType */); + var result = createNode(267 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21 /* CloseBracketToken */); return finishNode(result); @@ -18240,7 +19254,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261 /* JSDocUnionType */); + var result = createNode(266 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -18256,12 +19270,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258 /* JSDocAllType */); + var result = createNode(263 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282 /* JSDocLiteralType */); + var result = createNode(287 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -18284,17 +19298,17 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(259 /* JSDocUnknownType */, pos); + var result = createNode(264 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(263 /* JSDocNullableType */, pos); + var result = createNode(268 /* 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; @@ -18359,6 +19373,7 @@ var ts; } if (token() === 4 /* NewLineTrivia */) { state = 0 /* BeginningOfLine */; + indent = 0; nextJSDocToken(); } while (token() !== 1 /* EndOfFileToken */) { @@ -18447,7 +19462,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(273 /* JSDocComment */, start); + var result = createNode(278 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18560,7 +19575,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274 /* JSDocTag */, atToken.pos); + var result = createNode(279 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -18617,7 +19632,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275 /* JSDocParameterTag */, atToken.pos); + var result = createNode(280 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -18628,20 +19643,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 === 281 /* 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(281 /* 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 === 282 /* 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(282 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18656,7 +19671,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(285 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18666,18 +19681,25 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(284 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; - typedefTag.name = parseJSDocIdentifierName(); + typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); + if (typedefTag.fullName) { + var rightNode = typedefTag.fullName; + while (rightNode.kind !== 70 /* Identifier */) { + rightNode = rightNode.body; + } + typedefTag.name = rightNode; + } typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 272 /* 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(); } } @@ -18691,7 +19713,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18728,6 +19750,21 @@ var ts; scanner.setTextPos(resumePos); return finishNode(jsDocTypeLiteral); } + function parseJSDocTypeNameWithNamespace(flags) { + var pos = scanner.getTokenPos(); + var typeNameOrNamespaceName = parseJSDocIdentifierName(); + if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { + var jsDocNamespaceNode = createNode(230 /* ModuleDeclaration */, pos); + jsDocNamespaceNode.flags |= flags; + jsDocNamespaceNode.name = typeNameOrNamespaceName; + jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); + return jsDocNamespaceNode; + } + if (typeNameOrNamespaceName && flags & 4 /* NestedNamespace */) { + typeNameOrNamespaceName.isInJSDocNamespace = true; + } + return typeNameOrNamespaceName; + } } function tryParseChildTag(parentTag) { ts.Debug.assert(token() === 56 /* AtToken */); @@ -18749,30 +19786,34 @@ var ts; return true; case "prop": case "property": - if (!parentTag.jsDocPropertyTags) { - parentTag.jsDocPropertyTags = []; - } var propertyTag = parsePropertyTag(atToken, tagName); - parentTag.jsDocPropertyTags.push(propertyTag); - return true; + if (propertyTag) { + if (!parentTag.jsDocPropertyTags) { + parentTag.jsDocPropertyTags = []; + } + parentTag.jsDocPropertyTags.push(propertyTag); + return true; + } + // Error parsing property tag + return false; } 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 === 283 /* 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 */) { @@ -18783,7 +19824,7 @@ var ts; break; } } - var result = createNode(278 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(283 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -19294,25 +20335,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 === 227 /* InterfaceDeclaration */ || node.kind === 228 /* 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 === 235 /* ImportDeclaration */ || node.kind === 234 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 227 /* ModuleBlock */) { + else if (node.kind === 231 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19331,10 +20372,13 @@ var ts; }); return state_1; } - else if (node.kind === 226 /* ModuleDeclaration */) { + else if (node.kind === 230 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } + else if (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace) { + return 0 /* NonInstantiated */; + } else { return 1 /* Instantiated */; } @@ -19469,7 +20513,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 === 230 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19482,7 +20526,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)) { @@ -19494,21 +20538,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 241 /* ExportDeclaration */: return "__export"; - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19523,22 +20567,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: + case 225 /* FunctionDeclaration */: + case 226 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 269 /* JSDocFunctionType */: + case 274 /* 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 === 274 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 205 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -19625,7 +20669,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 === 240 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19645,7 +20689,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 === 243 /* ExportSpecifier */ || (node.kind === 234 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19668,7 +20712,11 @@ 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. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) { + var isJSDocTypedefInJSDocNamespace = node.kind === 284 /* JSDocTypedefTag */ && + node.name && + node.name.kind === 70 /* Identifier */ && + node.name.isInJSDocNamespace; + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793064 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1920 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -19726,8 +20774,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(); @@ -19746,13 +20794,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 === 261 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -19787,6 +20835,7 @@ var ts; skipTransformFlagAggregation = true; bindChildrenWorker(node); skipTransformFlagAggregation = false; + subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); } else { var savedSubtreeTransformFlags = subtreeTransformFlags; @@ -19807,64 +20856,64 @@ var ts; return; } switch (node.kind) { - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: bindWhileStatement(node); break; - case 205 /* DoStatement */: + case 209 /* DoStatement */: bindDoStatement(node); break; - case 207 /* ForStatement */: + case 211 /* ForStatement */: bindForStatement(node); break; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 204 /* IfStatement */: + case 208 /* IfStatement */: bindIfStatement(node); break; - case 212 /* ReturnStatement */: - case 216 /* ThrowStatement */: + case 216 /* ReturnStatement */: + case 220 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 217 /* TryStatement */: + case 221 /* TryStatement */: bindTryStatement(node); break; - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: bindSwitchStatement(node); break; - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: bindCaseBlock(node); break; - case 249 /* CaseClause */: + case 253 /* CaseClause */: bindCaseClause(node); break; - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: bindLabeledStatement(node); break; - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 175 /* CallExpression */: + case 179 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19876,15 +20925,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return hasNarrowableArgument(expr); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -19892,7 +20941,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 177 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19903,14 +20952,14 @@ var ts; } } } - if (expr.expression.kind === 173 /* PropertyAccessExpression */ && + if (expr.expression.kind === 177 /* 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 === 187 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -19931,9 +20980,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -20028,33 +21077,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204 /* IfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 208 /* IfStatement */: + case 210 /* WhileStatement */: + case 209 /* DoStatement */: return parent.expression === node; - case 207 /* ForStatement */: - case 189 /* ConditionalExpression */: + case 211 /* ForStatement */: + case 193 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 183 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 190 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 192 /* 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 === 183 /* ParenthesizedExpression */ || + node.parent.kind === 190 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -20096,8 +21145,13 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 219 /* 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); @@ -20128,7 +21182,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220 /* VariableDeclarationList */) { + if (node.initializer.kind !== 224 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20150,7 +21204,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212 /* ReturnStatement */) { + if (node.kind === 216 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20170,7 +21224,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 215 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20210,7 +21264,7 @@ var ts; currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it - // otherwise check if flows after try and after catch are unreachable + // otherwise check if flows after try and after catch are unreachable // if yes - convert current flow to unreachable // i.e. // try { return "1" } finally { console.log(1); } @@ -20236,7 +21290,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 === 254 /* 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; @@ -20299,11 +21353,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 !== 209 /* 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 === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20314,10 +21371,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171 /* ArrayLiteralExpression */) { + else if (node.kind === 175 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192 /* SpreadElementExpression */) { + if (e.kind === 196 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20325,15 +21382,18 @@ var ts; } } } - else if (node.kind === 172 /* ObjectLiteralExpression */) { + else if (node.kind === 176 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253 /* PropertyAssignment */) { + if (p.kind === 257 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254 /* ShorthandPropertyAssignment */) { + else if (p.kind === 258 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 259 /* SpreadAssignment */) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -20385,9 +21445,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 === 178 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20398,7 +21458,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 177 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20408,9 +21468,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); @@ -20429,7 +21491,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 === 212 /* ForInStatement */ || node.parent.parent.kind === 213 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20438,10 +21500,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 === 183 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { + if (expr.kind === 184 /* FunctionExpression */ || expr.kind === 185 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20449,7 +21511,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 177 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20458,51 +21520,52 @@ 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 197 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 176 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 286 /* JSDocTypeLiteral */: + case 270 /* JSDocRecordType */: return 1 /* IsContainer */; - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 269 /* JSDocFunctionType */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 274 /* JSDocFunctionType */: + case 230 /* ModuleDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 170 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 256 /* SourceFile */: + case 261 /* 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 225 /* 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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 227 /* ModuleBlock */: + case 231 /* 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 256 /* CatchClause */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 232 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 200 /* Block */: + case 204 /* 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 @@ -20539,41 +21602,42 @@ 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 230 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256 /* SourceFile */: + case 261 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 226 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225 /* EnumDeclaration */: + case 229 /* 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 176 /* ObjectLiteralExpression */: + case 227 /* InterfaceDeclaration */: + case 270 /* JSDocRecordType */: + case 286 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 274 /* JSDocFunctionType */: + case 228 /* TypeAliasDeclaration */: + case 170 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -20594,11 +21658,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 === 261 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 261 /* SourceFile */ || body.kind === 231 /* 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 === 241 /* ExportDeclaration */ || stat.kind === 240 /* ExportAssignment */) { return true; } } @@ -20691,7 +21755,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 === 259 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20703,7 +21767,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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20725,10 +21789,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -20839,8 +21903,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 !== 261 /* SourceFile */ && + blockScopeContainer.kind !== 230 /* 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. @@ -20906,7 +21970,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); @@ -20948,17 +22012,28 @@ var ts; switch (node.kind) { /* Strict mode checks */ case 70 /* Identifier */: + // for typedef type names with namespaces, bind the new jsdoc type symbol here + // because it requires all containing namespaces to be in effect, namely the + // current "blockScopeContainer" needs to be set to its immediate namespace parent. + if (node.isInJSDocNamespace) { + var parentNode = node.parent; + while (parentNode && parentNode.kind !== 284 /* 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 === 258 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20982,119 +22057,140 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return checkStrictModeCatchClause(node); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 213 /* WithStatement */: + case 217 /* 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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + if (node.dotDotDotToken && node.parent.kind === 172 /* ObjectBindingPattern */) { + emitFlags |= 32768 /* HasRestAttribute */; + } return bindVariableDeclarationOrBindingElement(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 266 /* JSDocRecordMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 271 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 280 /* JSDocPropertyTag */: + case 285 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 255 /* EnumMember */: + case 260 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 247 /* JsxSpreadAttribute */: - emitFlags |= 16384 /* HasJsxSpreadAttributes */; + case 259 /* SpreadAssignment */: + case 251 /* JsxSpreadAttribute */: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 176 /* ObjectLiteralExpression */ && + root.parent.kind === 192 /* 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 225 /* 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 274 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 265 /* JSDocRecordType */: + case 161 /* TypeLiteral */: + case 170 /* MappedType */: + case 286 /* JSDocTypeLiteral */: + case 270 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return bindFunctionExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 226 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 279 /* JSDocTypedefTag */: - case 224 /* TypeAliasDeclaration */: + case 284 /* JSDocTypedefTag */: + if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); + } + break; + case 228 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 230 /* ImportEqualsDeclaration */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 237 /* NamespaceImport */: + case 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 229 /* NamespaceExportDeclaration */: + case 233 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return bindImportClause(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return bindExportDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return bindExportAssignment(node); - case 256 /* SourceFile */: + case 261 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200 /* Block */: + case 204 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -21103,7 +22199,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); @@ -21126,7 +22222,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 === 240 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21136,17 +22232,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 !== 261 /* 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; } @@ -21191,12 +22287,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 === 225 /* FunctionDeclaration */ || container.kind === 184 /* 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; @@ -21247,7 +22343,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 226 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21391,13 +22487,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 !== 206 /* EmptyStatement */) || // report error on class declarations - node.kind === 222 /* ClassDeclaration */ || + node.kind === 226 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 230 /* 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 === 229 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21411,7 +22507,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 !== 205 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21431,54 +22527,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175 /* CallExpression */: + case 179 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 143 /* Parameter */: + case 144 /* Parameter */: return computeParameter(node, subtreeFlags); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 195 /* ExpressionWithTypeArguments */: + case 256 /* CatchClause */: + return computeCatchClause(node, subtreeFlags); + case 199 /* 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 234 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21492,21 +22590,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 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -21518,31 +22616,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 === 176 /* 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 === 175 /* 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; @@ -21554,21 +22655,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; @@ -21578,17 +22683,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 === 200 /* AsExpression */ + || expressionKind === 182 /* 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; @@ -21599,47 +22704,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. @@ -21650,19 +22755,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 |= 3072 /* AssertES2015 */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + 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; @@ -21672,11 +22785,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 @@ -21688,14 +22801,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; @@ -21708,7 +22821,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. @@ -21716,10 +22829,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; @@ -21731,11 +22844,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 */ @@ -21745,13 +22854,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 @@ -21759,11 +22872,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; @@ -21776,13 +22889,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 @@ -21790,14 +22907,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 */) @@ -21807,14 +22924,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; @@ -21823,24 +22944,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 === 172 /* ObjectBindingPattern */) { + transformFlags |= 48 /* AssertESNext */ | 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; + } + else if (nameKind === 173 /* 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; @@ -21852,26 +22977,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; @@ -21880,18 +23001,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 */; @@ -21900,29 +23021,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 189 /* AwaitExpression */: // async/await is ES2017 syntax - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; break; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: @@ -21930,84 +23051,86 @@ 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 229 /* EnumDeclaration */: + case 260 /* EnumMember */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: + case 201 /* NonNullExpression */: + case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 246 /* JsxElement */: + case 247 /* JsxSelfClosingElement */: + case 248 /* JsxOpeningElement */: case 10 /* JsxText */: - case 245 /* JsxClosingElement */: - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: - case 248 /* JsxExpression */: + case 249 /* JsxClosingElement */: + case 250 /* JsxAttribute */: + case 251 /* JsxSpreadAttribute */: + case 252 /* 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 213 /* 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 194 /* TemplateExpression */: + case 181 /* TaggedTemplateExpression */: + case 258 /* ShorthandPropertyAssignment */: + case 114 /* StaticKeyword */: // These nodes are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; - case 191 /* YieldExpression */: + case 195 /* 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 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 167 /* ThisType */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* MappedType */: + case 171 /* 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`), @@ -22016,75 +23139,151 @@ 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 196 /* SpreadElement */: + case 259 /* SpreadAssignment */: + // This node is ES6 or ES next syntax, but is handled by a containing node. + transformFlags |= 8388608 /* ContainsSpreadExpression */; break; + case 174 /* 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 172 /* ObjectBindingPattern */: + case 173 /* 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 176 /* 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 175 /* ArrayLiteralExpression */: + case 180 /* 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 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 211 /* ForStatement */: + case 212 /* 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 261 /* SourceFile */: + if (subtreeFlags & 524288 /* ContainsCapturedLexicalThis */) { + transformFlags |= 3072 /* AssertES2015 */; } break; - case 212 /* ReturnStatement */: - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: - transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; + case 216 /* ReturnStatement */: + case 214 /* ContinueStatement */: + case 215 /* BreakStatement */: + transformFlags |= 268435456 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; return transformFlags & ~excludeFlags; } + /** + * Gets the transform flags to exclude when unioning the transform flags of a subtree. + * + * NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`. + * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather + * than calling this function. + */ + /* @internal */ + function getTransformFlagsSubtreeExclusions(kind) { + if (kind >= 156 /* FirstTypeNode */ && kind <= 171 /* LastTypeNode */) { + return -3 /* TypeExcludes */; + } + switch (kind) { + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 175 /* ArrayLiteralExpression */: + return 545281365 /* ArrayLiteralOrCallOrNewExcludes */; + case 230 /* ModuleDeclaration */: + return 839734613 /* ModuleExcludes */; + case 144 /* Parameter */: + return 604001621 /* ParameterExcludes */; + case 185 /* ArrowFunction */: + return 979719509 /* ArrowFunctionExcludes */; + case 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + return 980243797 /* FunctionExcludes */; + case 224 /* VariableDeclarationList */: + return 604001621 /* VariableDeclarationListExcludes */; + case 226 /* ClassDeclaration */: + case 197 /* 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 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: + case 134 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 135 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 143 /* TypeParameter */: + case 146 /* PropertySignature */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + return -3 /* TypeExcludes */; + case 176 /* ObjectLiteralExpression */: + return 554784085 /* ObjectLiteralExcludes */; + default: + return 536892757 /* NodeExcludes */; + } + } + ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; })(ts || (ts = {})); /// /// @@ -22099,25 +23298,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) { @@ -22126,19 +23363,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 { @@ -22150,7 +23374,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -22162,7 +23385,9 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } } ts.getEffectiveTypeRoots = getEffectiveTypeRoots; /** @@ -22174,17 +23399,12 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_7 = ts.getDirectoryPath(currentDirectory); - if (parent_7 === currentDirectory) { - break; - } - currentDirectory = parent_7; - } + }); return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); @@ -22198,7 +23418,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -22221,64 +23440,59 @@ var ts; } } var failedLookupLocations = []; - // Check primary library paths - if (typeRoots && typeRoots.length) { + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_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) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + // Check primary library paths + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = 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); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + function secondaryLookup() { + var resolvedFile; + 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); } - else { + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; /** @@ -22417,15 +23631,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; } @@ -22463,7 +23677,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; } @@ -22482,7 +23696,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; } @@ -22493,7 +23707,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; } @@ -22509,70 +23723,82 @@ var ts; matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); 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; + // A path mapping may have a ".ts" extension; in contrast to an import, which should omit it. + var tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return path_1 && { path: path_1, extension: tsExtension }; } - } - return undefined; + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); } else { var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); 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, 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); + // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. + return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, 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 realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + 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) { @@ -22584,9 +23810,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; } @@ -22598,11 +23824,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); @@ -22610,12 +23836,21 @@ 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) { + function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); @@ -22626,30 +23861,34 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } - failedLookupLocation.push(fileName); + failedLookupLocations.push(fileName); return undefined; } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); if (directoryExists && state.host.fileExists(packageJsonPath)) { 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, failedLookupLocations, 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 */, failedLookupLocations, 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); } } } @@ -22658,101 +23897,106 @@ var ts; trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } // 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); + failedLookupLocations.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !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) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); + // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. + return loadModuleFromNodeModulesWorker(2 /* DtsOnly */, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ true); } - function loadModuleFromNodeModulesWorker(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; - } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; - } - directory = parentPath; + }); + } + /** Load a module from a single node_modules directory, but not from any ancestors' node_modules directories. */ + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== 1 /* JavaScript */) { + return loadModuleFromNodeModulesFolder(2 /* DtsOnly */, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); } - return undefined; } 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)) { + // Climb up parent directories looking for a module. + var resolved_3 = forEachAncestorDirectory(containingDirectory, function (directory) { + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, 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) { + /** + * 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 = loadModuleFromNodeModulesOneLevel(2 /* DtsOnly */, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ + function forEachAncestorDirectory(directory, callback) { while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - if (referencedSourceFile) { - return referencedSourceFile; + var result = callback(directory); + if (result !== undefined) { + return result; } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { return undefined; } - containingDirectory = parentPath; + directory = parentPath; } } })(ts || (ts = {})); @@ -22854,7 +24098,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(); @@ -22868,9 +24117,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 */ | 33554432 /* 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 */ | 33554432 /* 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"); @@ -22880,13 +24129,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 |= 134217728 /* 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); @@ -23045,6 +24298,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 = { @@ -23074,6 +24329,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. @@ -23157,7 +24427,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 === 230 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 230 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23219,7 +24489,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; } @@ -23260,8 +24530,11 @@ var ts; var nodeId = getNodeId(node); return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } + function getObjectFlags(type) { + return type.flags & 32768 /* Object */ ? type.objectFlags : 0; + } function isGlobalSourceFile(node) { - return node.kind === 256 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 261 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -23307,24 +24580,30 @@ var ts; // nodes are in different files and order cannot be determines return true; } + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + if (isUsedInFunctionOrNonStaticProperty(usage)) { + return true; + } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } 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 !== 223 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - return isUsedInFunctionOrNonStaticProperty(declaration, usage); + var container = ts.getEnclosingBlockScopeContainer(declaration); + return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201 /* VariableStatement */: - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 205 /* VariableStatement */: + case 211 /* ForStatement */: + case 213 /* 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)) { @@ -23333,8 +24612,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23342,8 +24621,7 @@ var ts; } return false; } - function isUsedInFunctionOrNonStaticProperty(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); + function isUsedInFunctionOrNonStaticProperty(usage, container) { var current = usage; while (current) { if (current === container) { @@ -23353,7 +24631,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) { @@ -23386,11 +24664,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 !== 278 /* 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 */) { @@ -23399,9 +24677,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) { @@ -23413,13 +24691,13 @@ var ts; } } switch (location.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 261 /* 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"]) { @@ -23442,7 +24720,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], 243 /* ExportSpecifier */)) { break; } } @@ -23450,13 +24728,13 @@ var ts; break loop; } break; - case 225 /* EnumDeclaration */: + case 229 /* 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 @@ -23473,9 +24751,9 @@ var ts; } } break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* 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 @@ -23486,7 +24764,7 @@ var ts; } break loop; } - if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 197 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23502,9 +24780,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 === 227 /* 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); @@ -23512,19 +24790,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 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23537,7 +24815,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. // @@ -23546,7 +24824,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; } // @@ -23609,7 +24887,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 === 233 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23663,9 +24941,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23687,7 +24965,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, 223 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23708,10 +24986,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 234 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 231 /* ImportDeclaration */) { + while (node && node.kind !== 235 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23721,7 +24999,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 === 245 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -23800,31 +25078,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; } @@ -23846,19 +25124,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return getTargetOfImportClause(node); - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 235 /* ImportSpecifier */: + case 239 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 229 /* NamespaceExportDeclaration */: + case 233 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -23905,11 +25183,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236 /* ExportAssignment */) { + if (node.kind === 240 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 239 /* ExportSpecifier */) { + else if (node.kind === 243 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -23931,13 +25209,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 === 234 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -23957,9 +25235,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 === 177 /* 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; @@ -23984,30 +25262,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 @@ -24025,15 +25303,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; @@ -24166,7 +25462,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; } } @@ -24188,8 +25484,9 @@ var ts; type.intrinsicName = "boolean"; return type; } - function createObjectType(kind, symbol) { - var type = createType(kind); + function createObjectType(objectFlags, symbol) { + var type = createType(32768 /* Object */); + type.objectFlags = objectFlags; type.symbol = symbol; return type; } @@ -24217,7 +25514,7 @@ var ts; } return result || emptyArray; } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { + function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; type.properties = getNamedMembers(members); type.callSignatures = callSignatures; @@ -24229,7 +25526,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - return setObjectTypeMembers(createObjectType(2097152 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -24241,11 +25538,11 @@ var ts; } } switch (location_1.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24286,7 +25583,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, 243 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24325,7 +25622,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, 243 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24340,10 +25637,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; @@ -24424,7 +25721,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -24465,12 +25762,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 === 177 /* PropertyAccessExpression */ || + entityName.parent.kind === 234 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24566,10 +25863,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 === 228 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24577,7 +25874,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 /* ModuleBlock */ && + node.parent.kind === 231 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24591,10 +25888,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return "(Anonymous class)"; - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24669,9 +25966,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_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_6) { + walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -24721,7 +26018,7 @@ var ts; } writer.writeKeyword("this"); } - else if (type.flags & 131072 /* Reference */) { + else if (getObjectFlags(type) & 4 /* Reference */) { writeTypeReference(type, nextFlags); } else if (type.flags & 256 /* EnumLiteral */) { @@ -24729,30 +26026,35 @@ var ts; writePunctuation(writer, 22 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } - else if (type.flags & (32768 /* Class */ | 65536 /* Interface */ | 16 /* Enum */ | 16384 /* TypeParameter */)) { + else if (getObjectFlags(type) & 3 /* ClassOrInterface */ || type.flags & (16 /* Enum */ | 16384 /* TypeParameter */)) { // 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 */) && ((type.flags & 2097152 /* Anonymous */ && !type.target) || type.flags & 1572864 /* UnionOrIntersection */) && type.aliasSymbol && + else if (!(flags & 512 /* InTypeAlias */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { - // We emit inferred type as type-alias at the current localtion if all the following is true - // the input type is has alias symbol that is accessible - // the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into) - // e.g.: export type Bar = () => [X, Y]; - // export type Foo = Bar; - // export const y = (x: Foo) => 1 // we want to emit as ...x: () => [any, string]) var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } - else if (type.flags & 1572864 /* UnionOrIntersection */) { + else if (type.flags & 196608 /* UnionOrIntersection */) { writeUnionOrIntersectionType(type, nextFlags); } - else if (type.flags & 2097152 /* Anonymous */) { + else if (getObjectFlags(type) & (16 /* Anonymous */ | 32 /* Mapped */)) { writeAnonymousType(type, nextFlags); } 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 // { ... } @@ -24800,7 +26102,7 @@ var ts; writePunctuation(writer, 20 /* OpenBracketToken */); writePunctuation(writer, 21 /* CloseBracketToken */); } - else if (type.target.flags & 262144 /* Tuple */) { + else if (type.target.objectFlags & 8 /* Tuple */) { writePunctuation(writer, 20 /* OpenBracketToken */); writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); writePunctuation(writer, 21 /* CloseBracketToken */); @@ -24816,14 +26118,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_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); // 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_7, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -24836,7 +26138,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 18 /* OpenParenToken */); } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); } else { @@ -24889,7 +26191,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 === 261 /* SourceFile */ || declaration.parent.kind === 231 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -24906,7 +26208,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 */); @@ -24924,7 +26226,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129 /* ReadonlyKeyword */); + writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -24945,6 +26247,12 @@ var ts; return false; } function writeLiteralType(type, flags) { + if (type.objectFlags & 32 /* Mapped */) { + if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { + writeMappedType(type); + return; + } + } var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { @@ -24981,6 +26289,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); @@ -24993,8 +26307,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); @@ -25017,9 +26331,32 @@ var ts; writer.writeLine(); } } + } + function writeMappedType(type) { + writePunctuation(writer, 16 /* OpenBraceToken */); + writer.writeLine(); + writer.increaseIndent(); + if (type.declaration.readonlyToken) { + writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeSpace(writer); + } + writePunctuation(writer, 20 /* OpenBracketToken */); + appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); + writeSpace(writer); + writeKeyword(writer, 91 /* InKeyword */); + writeSpace(writer); + writeType(getConstraintTypeFromMappedType(type), 0 /* None */); + writePunctuation(writer, 21 /* CloseBracketToken */); + if (type.declaration.questionToken) { + writePunctuation(writer, 54 /* QuestionToken */); + } + writePunctuation(writer, 55 /* ColonToken */); + writeSpace(writer); + writeType(getTemplateTypeFromMappedType(type), 0 /* None */); + writePunctuation(writer, 24 /* SemicolonToken */); + writer.writeLine(); writer.decreaseIndent(); writePunctuation(writer, 17 /* CloseBraceToken */); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -25058,12 +26395,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 === 172 /* 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 === 173 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -25077,7 +26414,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 174 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55 /* ColonToken */); @@ -25207,75 +26544,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170 /* BindingElement */: + case 174 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 219 /* VariableDeclaration */: + case 223 /* 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 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 225 /* FunctionDeclaration */: + case 229 /* EnumDeclaration */: + case 234 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_8 = 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 !== 234 /* ImportEqualsDeclaration */ && parent_8.kind !== 261 /* SourceFile */ && ts.isInAmbientContext(parent_8))) { + return isGlobalSourceFile(parent_8); } // 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_8); + 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 231 /* 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 236 /* ImportClause */: + case 237 /* NamespaceImport */: + case 239 /* 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 261 /* SourceFile */: + case 233 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return false; default: return false; @@ -25284,10 +26621,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 240 /* 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 === 243 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25362,7 +26699,6 @@ var ts; return getSymbolLinks(target).declaredType; } if (propertyName === 1 /* ResolvedBaseConstructorType */) { - ts.Debug.assert(!!(target.flags & 32768 /* Class */)); return target.resolvedBaseConstructorType; } if (propertyName === 3 /* ResolvedReturnType */) { @@ -25381,12 +26717,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 223 /* VariableDeclaration */: + case 224 /* VariableDeclarationList */: + case 239 /* ImportSpecifier */: + case 238 /* NamedImports */: + case 237 /* NamespaceImport */: + case 236 /* ImportClause */: node = node.parent; break; default: @@ -25419,22 +26755,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) { @@ -25454,25 +26798,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 === 172 /* 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 !== 198 /* 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 { @@ -25480,7 +26840,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) @@ -25496,10 +26860,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. @@ -25522,16 +26882,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 === 223 /* VariableDeclaration */ && + declaration.parent.kind === 224 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 205 /* 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); @@ -25547,14 +26907,14 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 175 /* 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. @@ -25564,10 +26924,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 === 212 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 209 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 213 /* 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, @@ -25581,7 +26941,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 === 223 /* 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. @@ -25594,11 +26954,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); @@ -25628,7 +26988,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 === 258 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -25659,12 +27019,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); @@ -25676,7 +27036,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; } return result; } @@ -25704,7 +27064,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 === 172 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25726,7 +27086,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 === 257 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -25743,7 +27103,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) { @@ -25755,14 +27115,14 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 252 /* CatchClause */) { + if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 236 /* ExportAssignment */) { + if (declaration.kind === 240 /* 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 === 285 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -25775,16 +27135,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 === 192 /* BinaryExpression */ || + declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* 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 === 192 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -25812,7 +27172,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 { @@ -25832,9 +27192,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; @@ -25877,7 +27237,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)); } } @@ -25888,11 +27248,11 @@ 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 { - var type = createObjectType(2097152 /* Anonymous */, symbol); + var type = createObjectType(16 /* Anonymous */, symbol); links.type = strictNullChecks && symbol.flags & 536870912 /* Optional */ ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } @@ -25950,7 +27310,7 @@ var ts; return unknownType; } function getTargetType(type) { - return type.flags & 131072 /* Reference */ ? type.target : type; + return getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } function hasBaseType(type, checkBase) { return check(type); @@ -25984,9 +27344,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 === 226 /* ClassDeclaration */ || node.kind === 197 /* ClassExpression */ || + node.kind === 225 /* FunctionDeclaration */ || node.kind === 184 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */ || node.kind === 185 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25996,7 +27356,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, 227 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -26005,8 +27365,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 === 227 /* InterfaceDeclaration */ || node.kind === 226 /* ClassDeclaration */ || + node.kind === 197 /* ClassExpression */ || node.kind === 228 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26021,7 +27381,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 2588672 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -26033,7 +27393,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { - var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); } return signatures; @@ -26053,7 +27413,7 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 2588672 /* ObjectType */) { + if (baseConstructorType.flags & 32768 /* Object */) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -26072,7 +27432,7 @@ var ts; } function getBaseTypes(type) { if (!type.resolvedBaseTypes) { - if (type.flags & 262144 /* Tuple */) { + if (type.objectFlags & 8 /* Tuple */) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { @@ -26092,7 +27452,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & 2588672 /* ObjectType */)) { + if (!(baseConstructorType.flags & 32768 /* Object */)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -26119,7 +27479,7 @@ var ts; if (baseType === unknownType) { return; } - if (!(getTargetType(baseType).flags & (32768 /* Class */ | 65536 /* Interface */))) { + if (!(getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */)) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -26149,12 +27509,12 @@ 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 === 227 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (32768 /* Class */ | 65536 /* Interface */)) { + if (getObjectFlags(getTargetType(baseType)) & 3 /* ClassOrInterface */) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -26181,7 +27541,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 === 227 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26204,7 +27564,7 @@ var ts; function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 32768 /* Class */ : 65536 /* Interface */; + var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; var type = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -26213,8 +27573,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 32768 /* Class */ || !isIndependentInterface(symbol)) { - type.flags |= 131072 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isIndependentInterface(symbol)) { + type.objectFlags |= 4 /* Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -26238,8 +27598,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 284 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -26250,16 +27609,17 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); - type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); + declaration = ts.getDeclarationOfKind(symbol, 228 /* TypeAliasDeclaration */); + type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { - links.typeParameters = typeParameters; + var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { // Initialize the instantiation cache for generic type aliases. The declared type corresponds to // an instantiation of the type alias with the type parameters supplied as type arguments. + links.typeParameters = typeParameters; links.instantiations = ts.createMap(); - links.instantiations[getTypeListId(links.typeParameters)] = type; + links.instantiations[getTypeListId(typeParameters)] = type; } } else { @@ -26276,14 +27636,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 190 /* 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 === 229 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26311,7 +27671,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 === 229 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26326,7 +27686,7 @@ var ts; } enumType.memberTypes = memberTypes; if (memberTypeList.length > 1) { - enumType.flags |= 524288 /* Union */; + enumType.flags |= 65536 /* Union */; enumType.types = memberTypeList; unionTypes[getTypeListId(memberTypeList)] = enumType; } @@ -26338,7 +27698,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - links.declaredType = enumType.flags & 524288 /* Union */ ? + links.declaredType = enumType.flags & 65536 /* Union */ ? enumType.memberTypes[getEnumMemberValue(symbol.valueDeclaration)] : enumType; } @@ -26349,7 +27709,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; @@ -26403,19 +27763,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 171 /* LiteralType */: return true; - case 161 /* ArrayType */: + case 162 /* ArrayType */: return isIndependentType(node.elementType); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26428,7 +27788,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++) { @@ -26449,12 +27809,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); } } @@ -26499,7 +27859,7 @@ var ts; return type; } function getTypeWithThisArgument(type, thisArgument) { - if (type.flags & 131072 /* Reference */) { + if (getObjectFlags(type) & 4 /* Reference */) { return createTypeReference(type.target, ts.concatenate(type.typeArguments, [thisArgument || type.target.thisType])); } return type; @@ -26522,8 +27882,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); } @@ -26543,7 +27903,7 @@ var ts; numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type) { resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); @@ -26578,14 +27938,14 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); - var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNodeNoAlias); + var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { 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); @@ -26682,7 +28042,7 @@ var ts; var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1, type2) { return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); @@ -26690,6 +28050,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). @@ -26704,17 +28067,17 @@ var ts; stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0 /* String */)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type) { 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); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; @@ -26722,7 +28085,7 @@ var ts; var constructSignatures = getSignaturesOfSymbol(members["__new"]); var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0 /* String */); var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1 /* Number */); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { // Combinations of function, class, enum and module @@ -26738,13 +28101,13 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 2588672 /* ObjectType */) { + if (baseConstructorType.flags & 32768 /* Object */) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -26754,21 +28117,95 @@ var ts; } } } + /** Resolve the members of a mapped type { [P in K]: T } */ + function resolveMappedTypeMembers(type) { + var members = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + // In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type, + // and T as the template type. + var typeParameter = getTypeParameterFromMappedType(type); + var constraintType = getConstraintTypeFromMappedType(type); + var templateType = getTemplateTypeFromMappedType(type); + var isReadonly = !!type.declaration.readonlyToken; + var isOptional = !!type.declaration.questionToken; + // First, if the constraint type is a type parameter, obtain the base constraint. Then, + // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Finally, iterate over the constituents of the resulting iteration type. + var keyType = constraintType.flags & 16384 /* TypeParameter */ ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 262144 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + forEachType(iterationType, function (t) { + // Create a mapper from T to the current iteration type constituent. Then, if the + // mapped type is itself an instantiated type, combine the iteration mapper with the + // instantiation mapper. + var iterationMapper = createUnaryTypeMapper(typeParameter, t); + var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; + var propType = instantiateType(templateType, templateMapper); + // If the current iteration type constituent is a literal type, create a property. + // Otherwise, for type string create a string index signature and for type number + // create a numeric index signature. + if (t.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */)) { + var propName = t.text; + var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); + prop.type = addOptionality(propType, isOptional); + prop.isReadonly = isReadonly; + members[propName] = prop; + } + else if (t.flags & 2 /* String */) { + stringIndexInfo = createIndexInfo(propType, isReadonly); + } + else if (t.flags & 4 /* Number */) { + numberIndexInfo = createIndexInfo(propType, isReadonly); + } + }); + // If we created both a string and a numeric string index signature, and if the two index + // signatures have identical types, discard the redundant numeric index signature. + if (stringIndexInfo && numberIndexInfo && isTypeIdenticalTo(stringIndexInfo.type, numberIndexInfo.type)) { + numberIndexInfo = undefined; + } + setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } + function getTypeParameterFromMappedType(type) { + return type.typeParameter || + (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter))); + } + function getConstraintTypeFromMappedType(type) { + return type.constraintType || + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + } + function getTemplateTypeFromMappedType(type) { + return type.templateType || + (type.templateType = type.declaration.type ? + instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + unknownType); + } + function isGenericMappedType(type) { + if (getObjectFlags(type) & 32 /* Mapped */) { + var constraintType = getConstraintTypeFromMappedType(type); + return !!(constraintType.flags & (16384 /* TypeParameter */ | 262144 /* Index */)); + } + return false; + } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Reference */) { - resolveTypeReferenceMembers(type); + if (type.flags & 32768 /* Object */) { + if (type.objectFlags & 4 /* Reference */) { + resolveTypeReferenceMembers(type); + } + else if (type.objectFlags & 3 /* ClassOrInterface */) { + resolveClassOrInterfaceMembers(type); + } + else if (type.objectFlags & 16 /* Anonymous */) { + resolveAnonymousTypeMembers(type); + } + else if (type.objectFlags & 32 /* Mapped */) { + resolveMappedTypeMembers(type); + } } - else if (type.flags & (32768 /* Class */ | 65536 /* Interface */)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 2097152 /* Anonymous */) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 524288 /* Union */) { + else if (type.flags & 65536 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 1048576 /* Intersection */) { + else if (type.flags & 131072 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -26776,7 +28213,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return emptyArray; @@ -26784,7 +28221,7 @@ var ts; /** If the given type is an object type and that type has a property by the given name, * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -26801,7 +28238,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { break; } } @@ -26821,7 +28258,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 1572864 /* 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 @@ -26843,28 +28282,19 @@ 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; var props; // Flags we want to propagate to the result if they exist in all source symbols - var commonFlags = (containingType.flags & 1048576 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; + var commonFlags = (containingType.flags & 131072 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; var isReadonly = false; var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { @@ -26884,7 +28314,7 @@ var ts; isReadonly = true; } } - else if (containingType.flags & 524288 /* Union */) { + else if (containingType.flags & 65536 /* Union */) { isPartial = true; } } @@ -26919,7 +28349,7 @@ var ts; result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; - result.type = containingType.flags & 524288 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); + result.type = containingType.flags & 65536 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } // Return the symbol for a given property in a union or intersection type, or undefined if the property @@ -26953,7 +28383,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -26967,13 +28397,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 1572864 /* UnionOrIntersection */) { + if (type.flags & 196608 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 4161536 /* StructuredType */) { + if (type.flags & 229376 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -26987,7 +28417,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 4161536 /* StructuredType */) { + if (type.flags & 229376 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -27022,7 +28452,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); @@ -27052,8 +28482,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 === 273 /* JSDocOptionalType */) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -27062,11 +28492,19 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 273 /* 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; @@ -27124,7 +28562,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167 /* LiteralType */) { + if (param.type && param.type.kind === 171 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -27138,10 +28576,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); @@ -27153,14 +28591,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); @@ -27177,7 +28615,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; @@ -27185,8 +28623,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)) { @@ -27200,20 +28638,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 225 /* 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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 274 /* 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). @@ -27277,13 +28715,18 @@ var ts; function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); - if (type.flags & 131072 /* Reference */ && type.target === globalArrayType) { + if (getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } } 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) { @@ -27300,8 +28743,8 @@ 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 type = createObjectType(2097152 /* Anonymous */); + var isConstructor = signature.declaration.kind === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; + var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -27314,7 +28757,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++) { @@ -27341,7 +28784,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; @@ -27374,7 +28817,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 = ""; @@ -27411,22 +28854,23 @@ var ts; result |= type.flags; } } - return result & 234881024 /* PropagatingFlags */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var propagatedFlags = typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; - var flags = 131072 /* Reference */ | propagatedFlags; - type = target.instantiations[id] = createObjectType(flags, target.symbol); + type = target.instantiations[id] = createObjectType(4 /* Reference */, target.symbol); + type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; } return type; } function cloneTypeReference(source) { - var type = createObjectType(source.flags, source.symbol); + var type = createType(source.flags); + type.symbol = source.symbol; + type.objectFlags = source.objectFlags; type.target = source.target; type.typeArguments = source.typeArguments; return type; @@ -27446,7 +28890,7 @@ var ts; // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias))); + return createTypeReference(type, ts.concatenate(type.outerTypeParameters, ts.map(node.typeArguments, getTypeFromTypeNode))); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -27454,21 +28898,26 @@ var ts; } return type; } + function getTypeAliasInstantiation(symbol, typeArguments) { + var type = getDeclaredTypeOfSymbol(symbol); + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + var id = getTypeListId(typeArguments); + return links.instantiations[id] || (links.instantiations[id] = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, typeArguments))); + } // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the // declared type. Instantiations are cached using the type identities of the type arguments as the key. function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); - var links = getSymbolLinks(symbol); - var typeParameters = links.typeParameters; + var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); return unknownType; } - var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNodeNoAlias); - var id = getTypeListId(typeArguments); - return links.instantiations[id] || (links.instantiations[id] = instantiateType(type, createTypeMapper(typeParameters, typeArguments))); + var typeArguments = ts.map(node.typeArguments, getTypeFromTypeNode); + return getTypeAliasInstantiation(symbol, typeArguments); } if (node.typeArguments) { error(node, ts.Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); @@ -27486,11 +28935,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156 /* TypeReference */: + case 157 /* TypeReference */: return node.typeName; - case 267 /* JSDocTypeReference */: + case 272 /* JSDocTypeReference */: return node.name; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27516,7 +28965,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 === 272 /* 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. @@ -27529,14 +28978,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267 /* JSDocTypeReference */) { + if (node.kind === 272 /* 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 @@ -27571,9 +29020,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: return declaration; } } @@ -27582,7 +29031,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 2588672 /* ObjectType */)) { + if (!(type.flags & 32768 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -27662,7 +29111,7 @@ var ts; property.type = typeParameter; properties.push(property); } - var type = createObjectType(262144 /* Tuple */ | 131072 /* Reference */); + var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -27689,7 +29138,7 @@ var ts; function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNodeNoAlias)); + links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); } return links.resolvedType; } @@ -27717,7 +29166,7 @@ var ts; } function addTypeToUnion(typeSet, type) { var flags = type.flags; - if (flags & 524288 /* Union */) { + if (flags & 65536 /* Union */) { addTypesToUnion(typeSet, type.types); } else if (flags & 1 /* Any */) { @@ -27728,7 +29177,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096 /* Null */) typeSet.containsNull = true; - if (!(flags & 33554432 /* ContainsWideningType */)) + if (!(flags & 2097152 /* ContainsWideningType */)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192 /* Never */)) { @@ -27741,7 +29190,8 @@ var ts; var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & 2097152 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { + if (!(flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } } @@ -27805,7 +29255,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 & 16777216 /* FreshLiteral */ && containsType(types, t.regularType); + t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 1048576 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -27855,22 +29305,22 @@ var ts; var type = unionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */); - type = unionTypes[id] = createObjectType(524288 /* Union */ | propagatedFlags); + type = unionTypes[id] = createType(65536 /* Union */ | propagatedFlags); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*subtypeReduction*/ false, getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } function addTypeToIntersection(typeSet, type) { - if (type.flags & 1048576 /* Intersection */) { + if (type.flags & 131072 /* Intersection */) { addTypesToIntersection(typeSet, type.types); } else if (type.flags & 1 /* Any */) { @@ -27888,6 +29338,11 @@ var ts; addTypeToIntersection(typeSet, type); } } + // We normalize combinations of intersection and union types based on the distributive property of the '&' + // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection + // types with union type constituents into equivalent union types with intersection type constituents and + // effectively ensure that union types are always at the top level in type representations. + // // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. @@ -27897,6 +29352,18 @@ var ts; if (types.length === 0) { return emptyObjectType; } + 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)); }), + /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments) }; + } + }; + for (var i = 0; i < types.length; i++) { + var state_2 = _loop_2(i); + if (typeof state_2 === "object") + return state_2.value; + } var typeSet = []; addTypesToIntersection(typeSet, types); if (typeSet.containsAny) { @@ -27909,40 +29376,256 @@ var ts; var type = intersectionTypes[id]; if (!type) { var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 6144 /* Nullable */); - type = intersectionTypes[id] = createObjectType(1048576 /* Intersection */ | propagatedFlags); + type = intersectionTypes[id] = createType(131072 /* Intersection */ | propagatedFlags); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } return type; } - function getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromIntersectionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNodeNoAlias), aliasSymbol, aliasTypeArguments); + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); } return links.resolvedType; } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144 /* Index */); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */ || 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) { - // Deferred resolution of members is handled by resolveObjectTypeMembers - var type = createObjectType(2097152 /* Anonymous */, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = getIndexType(getTypeFromTypeNode(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 === 178 /* 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 === 178 /* 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 (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + 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(getTypeFromTypeNode(node.objectType), getTypeFromTypeNode(node.indexType), node); + } + return links.resolvedType; + } + function getTypeFromMappedTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + var type = createObjectType(32 /* Mapped */, node.symbol); + type.declaration = node; + type.aliasSymbol = getAliasSymbolForTypeNode(node); + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); links.resolvedType = type; } return links.resolvedType; } + function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + // Deferred resolution of members is handled by resolveObjectTypeMembers + var aliasSymbol = getAliasSymbolForTypeNode(node); + if (ts.isEmpty(node.symbol.members) && !aliasSymbol) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16 /* Anonymous */, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + links.resolvedType = type; + } + } + return links.resolvedType; + } + function getAliasSymbolForTypeNode(node) { + return node.parent.kind === 228 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + } + function getAliasTypeArgumentsForTypeNode(node) { + var symbol = getAliasSymbolForTypeNode(node); + return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; + } + /** + * 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 & 16777216 /* FreshLiteral */)) { + if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 1048576 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 16777216 /* FreshLiteral */, type.text); + var freshType = createLiteralType(type.flags | 1048576 /* FreshLiteral */, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -27951,7 +29634,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 16777216 /* 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; @@ -27975,7 +29658,7 @@ var ts; function getTypeFromJSDocTupleType(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var types = ts.map(node.types, getTypeFromTypeNodeNoAlias); + var types = ts.map(node.types, getTypeFromTypeNode); links.resolvedType = createTupleType(types); } return links.resolvedType; @@ -27983,9 +29666,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 === 227 /* 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; } } @@ -27999,87 +29682,90 @@ var ts; } return links.resolvedType; } - function getTypeFromTypeNodeNoAlias(type) { - return getTypeFromTypeNode(type, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined); - } - function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { + function getTypeFromTypeNode(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 258 /* JSDocAllType */: - case 259 /* JSDocUnknownType */: + case 263 /* JSDocAllType */: + case 264 /* 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 288 /* JSDocNullKeyword */: return nullType; - case 284 /* JSDocUndefinedKeyword */: + case 289 /* JSDocUndefinedKeyword */: return undefinedType; - case 285 /* JSDocNeverKeyword */: + case 290 /* JSDocNeverKeyword */: return neverType; - case 166 /* ThisType */: + case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 167 /* LiteralType */: + case 171 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 282 /* JSDocLiteralType */: + case 287 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 156 /* TypeReference */: - case 267 /* JSDocTypeReference */: + case 157 /* TypeReference */: + case 272 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return booleanType; - case 195 /* ExpressionWithTypeArguments */: + case 199 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 161 /* ArrayType */: - case 260 /* JSDocArrayType */: + case 162 /* ArrayType */: + case 265 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 163 /* UnionType */: - case 261 /* JSDocUnionType */: - return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* 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 164 /* UnionType */: + case 266 /* JSDocUnionType */: + return getTypeFromUnionTypeNode(node); + case 165 /* IntersectionType */: + return getTypeFromIntersectionTypeNode(node); + case 166 /* ParenthesizedType */: + case 268 /* JSDocNullableType */: + case 269 /* JSDocNonNullableType */: + case 276 /* JSDocConstructorType */: + case 277 /* JSDocThisType */: + case 273 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 265 /* JSDocRecordType */: + case 270 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 269 /* JSDocFunctionType */: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 161 /* TypeLiteral */: + case 286 /* JSDocTypeLiteral */: + case 274 /* JSDocFunctionType */: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 168 /* TypeOperator */: + return getTypeFromTypeOperatorNode(node); + case 169 /* IndexedAccessType */: + return getTypeFromIndexedAccessTypeNode(node); + case 170 /* MappedType */: + return getTypeFromMappedTypeNode(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 267 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 270 /* JSDocVariadicType */: + case 275 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -28096,6 +29782,16 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } + function instantiateCached(type, mapper, instantiator) { + var instantiations = mapper.instantiations || (mapper.instantiations = []); + return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -28118,7 +29814,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) { @@ -28216,25 +29911,25 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - if (mapper.instantiations) { - var cachedType = mapper.instantiations[type.id]; - if (cachedType) { - return cachedType; - } - } - else { - mapper.instantiations = []; - } - // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - var result = createObjectType(2097152 /* Anonymous */ | 4194304 /* Instantiated */, type.symbol); - result.target = type; - result.mapper = mapper; + var result = createObjectType(16 /* Anonymous */ | 64 /* Instantiated */, type.symbol); + result.target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; + result.mapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; - mapper.instantiations[type.id] = result; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + return result; + } + function instantiateMappedType(type, mapper) { + var result = createObjectType(32 /* Mapped */ | 64 /* Instantiated */, type.symbol); + result.declaration = type.declaration; + result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + result.aliasSymbol = type.aliasSymbol; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); 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 @@ -28242,23 +29937,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 225 /* 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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28268,27 +29963,63 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 227 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226 /* ModuleDeclaration */: - case 256 /* SourceFile */: + case 230 /* ModuleDeclaration */: + case 261 /* SourceFile */: return false; } node = node.parent; } return false; } + function isTopLevelTypeAlias(symbol) { + if (symbol.declarations && symbol.declarations.length) { + var parentKind = symbol.declarations[0].parent.kind; + return parentKind === 261 /* SourceFile */ || parentKind === 231 /* ModuleBlock */; + } + return false; + } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.flags & 16384 /* TypeParameter */) { - return mapper(type); + // If we are instantiating a type that has a top-level type alias, obtain the instantiation through + // the type alias instead in order to share instantiations for the same type arguments. This can + // dramatically reduce the number of structurally identical types we generate. Note that we can only + // perform this optimization for top-level type aliases. Consider: + // + // function f1(x: T) { + // type Foo = { x: X, t: T }; + // let obj: Foo = { x: x }; + // return obj; + // } + // function f2(x: U) { return f1(x); } + // let z = f2(42); + // + // Above, the declaration of f2 has an inferred return type that is an instantiation of f1's Foo + // equivalent to { x: U, t: U }. When instantiating this return type, we can't go back to Foo's + // cache because all cached instantiations are of the form { x: ???, t: T }, i.e. they have not been + // instantiated for T. Instead, we need to further instantiate the { x: U, t: U } form. + if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { + if (type.aliasTypeArguments) { + return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + return type; } - if (type.flags & 2097152 /* Anonymous */) { + return instantiateTypeNoAlias(type, mapper); + } + return type; + } + function instantiateTypeNoAlias(type, mapper) { + if (type.flags & 16384 /* TypeParameter */) { + return mapper(type); + } + if (type.flags & 32768 /* Object */) { + if (type.objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. We skip instantiation @@ -28297,19 +30028,28 @@ var ts; // instantiation. return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && - (type.flags & 4194304 /* Instantiated */ || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateAnonymousType(type, mapper) : type; + (type.objectFlags & 64 /* Instantiated */ || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? + instantiateCached(type, mapper, instantiateAnonymousType) : type; } - if (type.flags & 131072 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + if (type.objectFlags & 32 /* Mapped */) { + return instantiateCached(type, mapper, instantiateMappedType); } - if (type.flags & 524288 /* Union */ && !(type.flags & 8190 /* Primitive */)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); - } - if (type.flags & 1048576 /* Intersection */) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + if (type.objectFlags & 4 /* Reference */) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } + if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { + return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 131072 /* Intersection */) { + 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; } function instantiateIndexInfo(info, mapper) { @@ -28318,27 +30058,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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -28353,7 +30093,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 185 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -28367,10 +30107,10 @@ var ts; return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(2097152 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -28573,7 +30313,7 @@ var ts; } if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256 /* RegularEnum */) || !(target.symbol.flags & 256 /* RegularEnum */) || - (source.flags & 524288 /* Union */) !== (target.flags & 524288 /* Union */)) { + (source.flags & 65536 /* Union */) !== (target.flags & 65536 /* Union */)) { return enumRelation[id] = false; } var targetEnumType = getTypeOfSymbol(target.symbol); @@ -28630,23 +30370,23 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 16777216 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 16777216 /* FreshLiteral */) { + if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 1048576 /* FreshLiteral */) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 2588672 /* ObjectType */ && target.flags & 2588672 /* ObjectType */) { + if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 4177920 /* StructuredOrTypeParameter */ || target.flags & 4177920 /* StructuredOrTypeParameter */) { + if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -28693,9 +30433,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); } @@ -28715,10 +30461,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 & 16777216 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 16777216 /* 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 @@ -28729,7 +30475,13 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (source.flags & 8388608 /* ObjectLiteral */ && source.flags & 16777216 /* FreshLiteral */) { + if (source.flags & 262144 /* Index */) { + // A keyof T is related to a union type containing both string and number + if (maybeTypeOfKind(target, 2 /* String */) && maybeTypeOfKind(target, 4 /* Number */)) { + return -1 /* True */; + } + } + if (getObjectFlags(source) & 128 /* ObjectLiteral */ && source.flags & 1048576 /* FreshLiteral */) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -28740,13 +30492,15 @@ var ts; // and intersection types are further deconstructed on the target side, we don't want to // make the check again (as it might fail for a partial target type). Therefore we obtain // the regular source type and proceed with that. - if (target.flags & 1572864 /* UnionOrIntersection */) { + if (target.flags & 196608 /* UnionOrIntersection */) { source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - // Note that these checks are specifically ordered to produce correct results. - if (source.flags & 524288 /* Union */) { + // Note that these checks are specifically ordered to produce correct results. In particular, + // we need to deconstruct unions before intersections (because unions are always at the top), + // and we need to handle "each" relations before "some" relations for the same kind of type. + if (source.flags & 65536 /* Union */) { if (relation === comparableRelation) { result = someTypeRelatedToType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */)); } @@ -28757,36 +30511,56 @@ var ts; return result; } } - else if (target.flags & 1048576 /* Intersection */) { - result = typeRelatedToEachType(source, target, reportErrors); - if (result) { + else if (target.flags & 65536 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { return result; } } - else { - // It is necessary to try these "some" checks on both sides because there may be nested "each" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 1048576 /* Intersection */) { - // Check to see if any constituents of the intersection are immediately related to the target. - // - // Don't report errors though. Checking whether a constituent is related to the source is not actually - // useful and leads to some confusing error messages. Instead it is better to let the below checks - // take care of this, or to not elaborate at all. For instance, - // - // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. - // - // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection - // than to report that 'D' is not assignable to 'A' or 'B'. - // - // - For a primitive type or type parameter (such as 'number = A & B') there is no point in - // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + else if (target.flags & 131072 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072 /* Intersection */) { + // Check to see if any constituents of the intersection are immediately related to the target. + // + // Don't report errors though. Checking whether a constituent is related to the source is not actually + // useful and leads to some confusing error messages. Instead it is better to let the below checks + // take care of this, or to not elaborate at all. For instance, + // + // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. + // + // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection + // than to report that 'D' is not assignable to 'A' or 'B'. + // + // - For a primitive type or type parameter (such as 'number = A & B') there is no point in + // breaking the intersection apart. + if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + 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; } } - if (target.flags & 524288 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { + } + else if (target.flags & 262144 /* Index */) { + // A keyof S is related to a keyof T if T is related to S. + if (source.flags & 262144 /* Index */) { + if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { + return result; + } + } + // 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; } } @@ -28806,32 +30580,43 @@ var ts; } } else { - if (source.flags & 131072 /* Reference */ && target.flags & 131072 /* Reference */ && source.target === target.target) { + if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - var apparentSource = getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (apparentSource.flags & (2588672 /* ObjectType */ | 1048576 /* Intersection */) && target.flags & 2588672 /* ObjectType */) { - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190 /* Primitive */); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; + if (isGenericMappedType(target)) { + // A type [P in S]: X is related to a type [P in T]: Y if T is related to S and X is related to Y. + if (isGenericMappedType(source)) { + if ((result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) && + (result = isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors))) { + return result; + } + } + } + else { + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentSource = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentSource.flags & (32768 /* Object */ | 131072 /* Intersection */) && target.flags & 32768 /* Object */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190 /* Primitive */); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } } if (reportErrors) { - if (source.flags & 2588672 /* ObjectType */ && target.flags & 8190 /* Primitive */) { + if (source.flags & 32768 /* Object */ && target.flags & 8190 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 2588672 /* ObjectType */ && globalObjectType === source) { + else if (source.symbol && source.flags & 32768 /* Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } reportRelationError(headMessage, source, target); @@ -28840,8 +30625,8 @@ var ts; } function isIdenticalTo(source, target) { var result; - if (source.flags & 2588672 /* ObjectType */ && target.flags & 2588672 /* ObjectType */) { - if (source.flags & 131072 /* Reference */ && target.flags & 131072 /* Reference */ && source.target === target.target) { + if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { + if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // We have type references to same target type, see if all type arguments are identical if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; @@ -28849,8 +30634,8 @@ var ts; } return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); } - if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ || - source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { + if (source.flags & 65536 /* Union */ && target.flags & 65536 /* Union */ || + source.flags & 131072 /* Intersection */ && target.flags & 131072 /* Intersection */) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -28864,7 +30649,7 @@ var ts; // index signatures, or if the property is actually declared in the object type. In a union or intersection // type, a property is considered known if it is known in any constituent type. function isKnownProperty(type, name) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || @@ -28873,7 +30658,7 @@ var ts; return true; } } - else if (type.flags & 1572864 /* UnionOrIntersection */) { + else if (type.flags & 196608 /* UnionOrIntersection */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name)) { @@ -28891,8 +30676,7 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (maybeTypeOfKind(target, 2588672 /* ObjectType */) && - (!(target.flags & 2588672 /* ObjectType */) || !target.isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -28925,7 +30709,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 524288 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 65536 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } var len = targetTypes.length; @@ -28952,7 +30736,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 524288 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 65536 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -29083,9 +30867,9 @@ var ts; } var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 8388608 /* ObjectLiteral */); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); + 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) { @@ -29137,7 +30921,8 @@ var ts; return 0 /* False */; } result &= related; - if (sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { + // When checking for comparability, be more lenient with optional properties. + if (relation !== comparableRelation && sourceProp.flags & 536870912 /* Optional */ && !(targetProp.flags & 536870912 /* Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -29156,7 +30941,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 2588672 /* ObjectType */ && target.flags & 2588672 /* ObjectType */)) { + if (!(source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -29341,7 +31126,7 @@ var ts; } // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { - if (type.flags & 2097152 /* Anonymous */) { + if (getObjectFlags(type) & 16 /* Anonymous */) { var symbol = type.symbol; if (symbol && symbol.flags & 32 /* Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); @@ -29359,12 +31144,12 @@ var ts; // some level beyond that. function isDeeplyNestedGeneric(type, stack, depth) { // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (131072 /* Reference */ | 4194304 /* Instantiated */) && depth >= 5) { + if (getObjectFlags(type) & (4 /* Reference */ | 64 /* Instantiated */) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (131072 /* Reference */ | 4194304 /* Instantiated */) && t.symbol === symbol) { + if (getObjectFlags(t) & (4 /* Reference */ | 64 /* Instantiated */) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -29550,12 +31335,12 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isArrayType(type) { - return type.flags & 131072 /* Reference */ && type.target === globalArrayType; + return getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return type.flags & 131072 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || + return getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || !(type.flags & 6144 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isTupleLikeType(type) { @@ -29566,7 +31351,7 @@ var ts; } function isLiteralType(type) { return type.flags & 8 /* Boolean */ ? true : - type.flags & 524288 /* Union */ ? type.flags & 16 /* Enum */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + type.flags & 65536 /* Union */ ? type.flags & 16 /* Enum */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { @@ -29574,15 +31359,15 @@ var ts; type.flags & 64 /* NumberLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 32 /* StringLiteral */ && type.flags & 16777216 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 16777216 /* 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 & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } /** @@ -29590,7 +31375,7 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ function isTupleType(type) { - return !!(type.flags & 131072 /* Reference */ && type.target.flags & 262144 /* Tuple */); + return !!(getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getFalsyFlagsOfTypes(types) { var result = 0; @@ -29604,7 +31389,7 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 524288 /* Union */ ? getFalsyFlagsOfTypes(type.types) : + return type.flags & 65536 /* Union */ ? getFalsyFlagsOfTypes(type.types) : type.flags & 32 /* StringLiteral */ ? type.text === "" ? 32 /* StringLiteral */ : 0 : type.flags & 64 /* NumberLiteral */ ? type.text === "0" ? 64 /* NumberLiteral */ : 0 : type.flags & 128 /* BooleanLiteral */ ? type === falseType ? 128 /* BooleanLiteral */ : 0 : @@ -29674,7 +31459,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(type.flags & 8388608 /* ObjectLiteral */ && type.flags & 16777216 /* FreshLiteral */)) { + if (!(getObjectFlags(type) & 128 /* ObjectLiteral */ && type.flags & 1048576 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -29684,7 +31469,8 @@ 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 & ~16777216 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~1048576 /* FreshLiteral */; + regularNew.objectFlags |= 128 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; } @@ -29701,14 +31487,14 @@ var ts; return type.flags & 6144 /* Nullable */ ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 100663296 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & 6144 /* Nullable */) { return anyType; } - if (type.flags & 8388608 /* ObjectLiteral */) { + if (getObjectFlags(type) & 128 /* ObjectLiteral */) { return getWidenedTypeOfObjectLiteral(type); } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { @@ -29730,7 +31516,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; if (reportWideningErrorsInType(t)) { @@ -29746,11 +31532,11 @@ var ts; } } } - if (type.flags & 8388608 /* ObjectLiteral */) { + if (getObjectFlags(type) & 128 /* ObjectLiteral */) { for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 33554432 /* 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))); } @@ -29764,25 +31550,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 174 /* 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 225 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29795,7 +31581,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 33554432 /* 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); @@ -29843,10 +31629,12 @@ var ts; // we perform type inference (i.e. a type parameter of a generic function). We cache // results for union and intersection types for performance reasons. function couldContainTypeParameters(type) { + var objectFlags = getObjectFlags(type); return !!(type.flags & 16384 /* TypeParameter */ || - type.flags & 131072 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) || - type.flags & 2097152 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || - type.flags & 1572864 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type)); + objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || + objectFlags & 32 /* Mapped */ || + type.flags & 196608 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type)); } function couldUnionOrIntersectionContainTypeParameters(type) { if (type.couldContainTypeParameters === undefined) { @@ -29855,7 +31643,7 @@ var ts; return type.couldContainTypeParameters; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 1572864 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || type.flags & 196608 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function inferTypes(context, originalSource, originalTarget) { var typeParameters = context.signature.typeParameters; @@ -29877,8 +31665,18 @@ var ts; if (!couldContainTypeParameters(target)) { return; } - if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ && !(source.flags & 16 /* Enum */ && target.flags & 16 /* Enum */) || - source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { + if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + var sourceTypes = source.aliasTypeArguments; + var targetTypes = target.aliasTypeArguments; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + return; + } + if (source.flags & 65536 /* Union */ && target.flags & 65536 /* Union */ && !(source.flags & 16 /* Enum */ && target.flags & 16 /* Enum */) || + source.flags & 131072 /* Intersection */ && target.flags & 131072 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -29923,7 +31721,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 & 134217728 /* ContainsAnyFunctionType */) { + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -29950,7 +31748,7 @@ var ts; } } } - else if (source.flags & 131072 /* Reference */ && target.flags & 131072 /* Reference */ && source.target === target.target) { + else if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments var sourceTypes = source.typeArguments || emptyArray; var targetTypes = target.typeArguments || emptyArray; @@ -29959,7 +31757,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 1572864 /* UnionOrIntersection */) { + else if (target.flags & 196608 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter = void 0; @@ -29983,7 +31781,7 @@ var ts; inferiority--; } } - else if (source.flags & 1572864 /* UnionOrIntersection */) { + else if (source.flags & 196608 /* UnionOrIntersection */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -29992,8 +31790,21 @@ var ts; } } else { + if (getObjectFlags(target) & 32 /* Mapped */) { + var constraintType = getConstraintTypeFromMappedType(target); + if (getObjectFlags(source) & 32 /* Mapped */) { + inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + return; + } + if (constraintType.flags & 16384 /* TypeParameter */) { + inferFromTypes(getIndexType(source), constraintType); + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return; + } + } source = getApparentType(source); - if (source.flags & 2588672 /* ObjectType */) { + if (source.flags & 32768 /* Object */) { if (isInProcess(source, target)) { return; } @@ -30022,8 +31833,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)); @@ -30093,7 +31904,7 @@ var ts; reducedTypes.push(t); } } - return type.flags & 524288 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 65536 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function getInferenceCandidates(context, index) { var inferences = context.inferences[index]; @@ -30101,7 +31912,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]; @@ -30171,10 +31982,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: @@ -30195,7 +32006,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 173 /* PropertyAccessExpression */) { + if (node.kind === 177 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30206,7 +32017,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -30215,19 +32026,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 === 223 /* VariableDeclaration */ || target.kind === 174 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 173 /* PropertyAccessExpression */: - return target.kind === 173 /* PropertyAccessExpression */ && + case 177 /* PropertyAccessExpression */: + return target.kind === 177 /* 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 === 177 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30240,7 +32051,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 === 177 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -30248,14 +32059,14 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173 /* PropertyAccessExpression */) { + if (expr.kind === 177 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 524288 /* Union */) { + if (type && type.flags & 65536 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -30278,7 +32089,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 177 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30292,7 +32103,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 524288 /* Union */)) { + if (!(source.flags & 65536 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -30360,7 +32171,7 @@ var ts; type === falseType ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : type === falseType ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; } - if (flags & 2588672 /* ObjectType */) { + if (flags & 32768 /* Object */) { return isFunctionObjectType(type) ? strictNullChecks ? 6164448 /* FunctionStrictFacts */ : 8376288 /* FunctionFacts */ : strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; @@ -30378,7 +32189,7 @@ var ts; var constraint = getConstraintOfTypeParameter(type); return getTypeFacts(constraint || emptyObjectType); } - if (flags & 1572864 /* UnionOrIntersection */) { + if (flags & 196608 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } return 8388607 /* All */; @@ -30394,7 +32205,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 */) || @@ -30405,19 +32216,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 === 175 /* ArrayLiteralExpression */ || node.parent.kind === 257 /* 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); @@ -30428,21 +32239,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return stringType; - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return undefinedType; - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192 /* SpreadElementExpression */: - return getAssignedTypeOfSpreadElement(parent); - case 253 /* PropertyAssignment */: + case 196 /* SpreadElement */: + return getAssignedTypeOfSpreadExpression(parent); + case 257 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -30450,11 +32261,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 === 172 /* 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) { @@ -30468,35 +32279,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208 /* ForInStatement */) { + if (node.parent.parent.kind === 212 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.parent.kind === 213 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 /* VariableDeclaration */ ? + return node.kind === 223 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? + return node.kind === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 /* VariableDeclaration */ && node.initializer && + return node.kind === 223 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + node.kind !== 174 /* BindingElement */ && node.parent.kind === 192 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -30508,13 +32319,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 === 183 /* ParenthesizedExpression */ || + parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 192 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249 /* CaseClause */) { + if (clause.kind === 253 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -30531,13 +32342,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 524288 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 65536 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 524288 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 65536 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 524288 /* Union */) { + if (source.flags & 65536 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -30551,8 +32362,11 @@ var ts; } return containsType(target.types, source); } + function forEachType(type, f) { + return type.flags & 65536 /* Union */ ? ts.forEach(type.types, f) : f(type); + } function filterType(type, f) { - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered); @@ -30560,7 +32374,7 @@ var ts; return f(type) ? type : neverType; } function mapType(type, f) { - return type.flags & 524288 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); + return type.flags & 65536 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -30593,7 +32407,7 @@ var ts; // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(2097152 /* Anonymous */); + var result = createObjectType(256 /* EvolvingArray */); result.elementType = elementType; return result; } @@ -30607,13 +32421,10 @@ var ts; var elementType = getBaseTypeOfLiteralType(checkExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } - function isEvolvingArrayType(type) { - return !!(type.flags & 2097152 /* Anonymous */ && type.elementType); - } function createFinalArrayType(elementType) { return elementType.flags & 8192 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 524288 /* Union */ ? + createArrayType(elementType.flags & 65536 /* Union */ ? getUnionType(elementType.types, /*subtypeReduction*/ true) : elementType); } @@ -30622,17 +32433,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return isEvolvingArrayType(type) ? type.elementType : neverType; + return getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { var t = types_12[_i]; if (!(t.flags & 8192 /* Never */)) { - if (!isEvolvingArrayType(t)) { + if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -30653,20 +32464,40 @@ 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 === 177 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 179 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 178 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.kind === 192 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); return isLengthPushOrUnshift || isElementAssignment; } + function maybeTypePredicateCall(node) { + var links = getNodeLinks(node); + if (links.maybeTypePredicate === undefined) { + links.maybeTypePredicate = getMaybeTypePredicate(node); + } + return links.maybeTypePredicate; + } + function getMaybeTypePredicate(node) { + if (node.expression.kind !== 96 /* SuperKeyword */) { + var funcType = checkNonNullExpression(node.expression); + if (funcType !== silentNeverType) { + var apparentType = getApparentType(funcType); + if (apparentType !== unknownType) { + var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); + return !!ts.forEach(callSignatures, function (sig) { return sig.typePredicate; }); + } + } + } + return false; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -30679,8 +32510,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 201 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -30729,7 +32560,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 !== 177 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30755,7 +32586,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)); } @@ -30766,7 +32597,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 524288 /* Union */) { + if (declaredType.flags & 65536 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -30783,15 +32614,15 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 /* CallExpression */ ? + var expr = node.kind === 179 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (isEvolvingArrayType(type)) { + if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 175 /* CallExpression */) { + if (node.kind === 179 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -30946,8 +32777,8 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 /* PropertyAccessExpression */ && - declaredType.flags & 524288 /* Union */ && + return expr.kind === 177 /* PropertyAccessExpression */ && + declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); } @@ -30980,10 +32811,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 === 187 /* 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 === 187 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -31029,7 +32860,7 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 2589185 /* NotUnionOrUnit */) { + if (type.flags & 33281 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { @@ -31056,7 +32887,7 @@ var ts; if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 524288 /* Union */)) { + if (assumeTrue && !(type.flags & 65536 /* Union */)) { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. @@ -31118,10 +32949,10 @@ var ts; if (!targetType) { // Target type is type of construct signature var constructSignatures = void 0; - if (rightType.flags & 65536 /* Interface */) { + if (getObjectFlags(rightType) & 2 /* Interface */) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 2097152 /* Anonymous */) { + else if (getObjectFlags(rightType) & 16 /* Anonymous */) { constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); } if (constructSignatures && constructSignatures.length) { @@ -31139,7 +32970,7 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var assignableType = filterType(type, function (t) { return isTypeInstanceOf(t, candidate); }); if (!(assignableType.flags & 8192 /* Never */)) { return assignableType; @@ -31157,7 +32988,7 @@ var ts; getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { return type; } var signature = getResolvedSignature(callExpression); @@ -31181,10 +33012,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 === 178 /* ElementAccessExpression */ || invokedExpression.kind === 177 /* 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); } @@ -31201,15 +33032,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -31241,19 +33072,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 === 231 /* ModuleBlock */ || + node.kind === 261 /* SourceFile */ || + node.kind === 147 /* PropertyDeclaration */) { return node; } } @@ -31285,7 +33110,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; } } @@ -31299,6 +33124,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 @@ -31308,16 +33136,17 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 185 /* 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); @@ -31329,7 +33158,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 === 226 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31341,14 +33170,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193 /* ClassExpression */) { + else if (declaration_1.kind === 197 /* 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 */; } @@ -31363,23 +33192,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 === 184 /* FunctionExpression */ || + flowContainer.kind === 185 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -31407,7 +33247,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; @@ -31422,7 +33262,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 === 256 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -31447,8 +33287,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 === 211 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 224 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31462,7 +33302,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 179 /* ParenthesizedExpression */) { + while (current.parent.kind === 183 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31470,7 +33310,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 === 190 /* PrefixUnaryExpression */ || current.parent.kind === 191 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -31491,7 +33331,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 */; } @@ -31539,7 +33379,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 @@ -31560,32 +33400,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 185 /* 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 230 /* 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 229 /* 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; } @@ -31597,7 +33437,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 === 184 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31634,28 +33474,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 === 274 /* 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 === 277 /* 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 === 179 /* 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 === 185 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -31669,16 +33509,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 === 176 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31749,7 +33589,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 */; } @@ -31763,7 +33603,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 === 176 /* 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; @@ -31783,7 +33623,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; @@ -31798,7 +33638,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) @@ -31806,21 +33646,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 === 176 /* 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 */; } } } @@ -31828,7 +33668,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 185 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -31894,7 +33734,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; @@ -31905,11 +33745,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); } @@ -31946,7 +33786,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; @@ -31957,8 +33797,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 @@ -31980,7 +33820,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177 /* TaggedTemplateExpression */) { + if (template.parent.kind === 181 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -32018,7 +33858,7 @@ var ts; // is a union type, the mapping function is applied to each constituent type and a union of the resulting // types is returned. function applyToContextualType(type, mapper) { - if (!(type.flags & 524288 /* Union */)) { + if (!(type.flags & 65536 /* Union */)) { return mapper(type); } var types = type.types; @@ -32043,7 +33883,7 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = t.flags & 4161536 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 229376 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } @@ -32052,7 +33892,7 @@ var ts; } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 524288 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 65536 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -32108,13 +33948,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246 /* JsxAttribute */) { + if (attribute.kind === 250 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247 /* JsxSpreadAttribute */) { + else if (attribute.kind === 251 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -32152,58 +33992,73 @@ 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 223 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 174 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 181 /* ArrowFunction */: - case 212 /* ReturnStatement */: + case 185 /* ArrowFunction */: + case 216 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 198 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); + case 202 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 194 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return getContextualType(parent); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return getContextualType(parent); - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxAttribute */: + case 251 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; } // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. - function getNonGenericSignature(type) { + function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); if (signatures.length === 1) { var signature = signatures[0]; - if (!signature.typeParameters) { + if (!signature.typeParameters && !isAritySmaller(signature, node)) { return signature; } } } + /** If the contextual signature has fewer parameters than the function expression, do not use it */ + function isAritySmaller(signature, target) { + var targetParameterCount = 0; + for (; targetParameterCount < target.parameters.length; targetParameterCount++) { + var param = target.parameters[targetParameterCount]; + if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { + break; + } + } + if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { + targetParameterCount--; + } + var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; + return sourceLength < targetParameterCount; + } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; + return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -32222,19 +34077,19 @@ 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; } - if (!(type.flags & 524288 /* Union */)) { - return getNonGenericSignature(type); + if (!(type.flags & 65536 /* Union */)) { + return getNonGenericSignature(type, node); } var signatureList; var types = type.types; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var current = types_14[_i]; - var signature = getNonGenericSignature(current); + var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature @@ -32278,7 +34133,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 @@ -32289,8 +34144,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 === 174 /* BindingElement */ && !!node.initializer) || + (node.kind === 192 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -32299,7 +34154,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 === 196 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32323,7 +34178,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 196 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32338,7 +34193,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 === 173 /* ArrayBindingPattern */ || pattern.kind === 175 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32346,7 +34201,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194 /* OmittedExpression */) { + if (patternElement.kind !== 198 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32363,7 +34218,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, @@ -32431,9 +34286,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 === 172 /* ObjectBindingPattern */ || contextualType.pattern.kind === 176 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32441,18 +34298,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 === 257 /* PropertyAssignment */ || + memberDecl.kind === 258 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253 /* PropertyAssignment */) { + if (memberDecl.kind === 257 /* 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 === 258 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -32460,8 +34317,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 === 257 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 258 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -32469,8 +34326,7 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & 2588672 /* ObjectType */ && contextualType.isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.name); @@ -32490,13 +34346,30 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 259 /* 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)) { @@ -32526,18 +34399,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 : 16777216 /* FreshLiteral */; - result.flags |= 8388608 /* ObjectLiteral */ | 67108864 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 234881024 /* PropagatingFlags */); - if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + 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 |= 128 /* ObjectLiteral */; + if (patternWithComputedProperties) { + result.objectFlags |= 512 /* 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); @@ -32557,13 +34445,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 252 /* JsxExpression */: checkJsxExpression(child); break; - case 242 /* JsxElement */: + case 246 /* JsxElement */: checkJsxElement(child); break; - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32582,7 +34470,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 177 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32600,7 +34488,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; } @@ -32693,7 +34581,7 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node, valueType) { - ts.Debug.assert(!(valueType.flags & 524288 /* Union */)); + ts.Debug.assert(!(valueType.flags & 65536 /* Union */)); if (isTypeAny(valueType)) { // Short-circuit if the class tag is using an element type 'any' return anyType; @@ -32751,7 +34639,7 @@ var ts; if (!elemType) { elemType = checkExpression(node.tagName); } - if (elemType.flags & 524288 /* Union */) { + if (elemType.flags & 65536 /* Union */) { var types = elemType.types; return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); @@ -32825,7 +34713,7 @@ var ts; // Props is of type 'any' or unknown return attributesType; } - else if (attributesType.flags & 524288 /* Union */) { + else if (attributesType.flags & 65536 /* Union */) { // Props cannot be a union type error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); return anyType; @@ -32914,13 +34802,19 @@ 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) { - getSymbolLinks(reactSym).referenced = true; + // Mark local symbol as referenced here because it might not have been marked + // if jsx emit was not react as there wont be error being emitted + reactSym.isReferenced = true; + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 8388608 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + markAliasSymbolAsReferenced(reactSym); + } } var targetAttributesType = getJsxElementAttributesType(node); var nameTable = ts.createMap(); @@ -32929,11 +34823,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 === 250 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 251 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -32963,7 +34857,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; @@ -32982,7 +34876,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 === 177 /* PropertyAccessExpression */ || node.kind === 223 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -32993,7 +34887,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); @@ -33047,7 +34941,7 @@ var ts; type = getConstraintOfTypeParameter(type); } // TODO: why is the first part of this check here? - if (!(getTargetType(type).flags & (32768 /* Class */ | 65536 /* Interface */) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & 3 /* ClassOrInterface */ && hasBaseType(type, enclosingClass))) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -33073,6 +34967,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) { @@ -33090,47 +35011,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 !== 177 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && - !(prop.flags & 8192 /* Method */ && propType.flags & 524288 /* Union */)) { + !(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 & 524288 /* 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 === 177 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -33147,7 +35053,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer.kind === 224 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -33169,14 +35075,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 === 212 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -33190,10 +35096,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 === 180 /* 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); @@ -33203,101 +35110,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. @@ -33334,10 +35158,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 181 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 144 /* Decorator */) { + else if (node.kind !== 145 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33367,13 +35191,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_9 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_9 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_9; index = cutoffIndex; } } @@ -33381,7 +35205,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_9; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -33403,7 +35227,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 === 196 /* SpreadElement */) { return i; } } @@ -33416,13 +35240,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 === 181 /* 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 === 194 /* 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; @@ -33439,7 +35263,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); @@ -33448,7 +35272,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 === 180 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33479,7 +35303,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 2588672 /* ObjectType */) { + if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -33532,7 +35356,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 !== 198 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -33589,7 +35413,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 !== 180 /* 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. @@ -33606,7 +35430,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 !== 198 /* 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); @@ -33628,12 +35452,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 === 179 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 173 /* PropertyAccessExpression */) { + if (callee.kind === 177 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 174 /* ElementAccessExpression */) { + else if (callee.kind === 178 /* ElementAccessExpression */) { return callee.expression; } } @@ -33649,16 +35473,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 181 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 190 /* TemplateExpression */) { + if (template.kind === 194 /* 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. @@ -33683,19 +35507,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 226 /* ClassDeclaration */: + case 197 /* 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. @@ -33705,7 +35529,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; @@ -33729,25 +35553,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 226 /* 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 @@ -33774,21 +35598,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 226 /* 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 @@ -33799,7 +35623,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; @@ -33825,21 +35649,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 === 226 /* 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); @@ -33871,10 +35695,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 === 181 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -33886,8 +35710,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 === 181 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -33896,11 +35720,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 === 181 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -33909,8 +35733,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 === 181 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 145 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -33981,7 +35805,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 === 179 /* 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 @@ -34020,7 +35844,7 @@ var ts; else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { var typeArguments_2 = node.typeArguments; - checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNodeNoAlias), /*reportErrors*/ true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, typeArguments_2, ts.map(typeArguments_2, getTypeFromTypeNode), /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); @@ -34047,7 +35871,7 @@ var ts; var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { - candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNodeNoAlias)); + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); } return candidate; } @@ -34079,7 +35903,7 @@ var ts; if (candidate.typeParameters) { var typeArgumentTypes = void 0; if (typeArguments) { - typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNodeNoAlias); + typeArgumentTypes = ts.map(typeArguments, getTypeFromTypeNode); typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { @@ -34195,7 +36019,7 @@ var ts; if (!numCallSignatures && !numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have // no common signatures. - if (funcType.flags & 524288 /* Union */) { + if (funcType.flags & 65536 /* Union */) { return false; } return isTypeAssignableTo(funcType, globalFunctionType); @@ -34329,16 +36153,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 197 /* 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; } } @@ -34368,13 +36192,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175 /* CallExpression */: + case 179 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144 /* Decorator */: + case 145 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34423,12 +36247,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 176 /* NewExpression */) { + if (node.kind === 180 /* 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 @@ -34448,14 +36272,37 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && - ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && - // Make sure require is not a local function - !resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (ts.isInJavaScriptFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); } + function isCommonJsRequire(node) { + if (!ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + return false; + } + // Make sure require is not a local function + var resolvedRequire = resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!resolvedRequire) { + // project does not contain symbol named 'require' - assume commonjs require + return true; + } + // project includes symbol named 'require' - make sure that it it ambient and local non-alias + if (resolvedRequire.flags & 8388608 /* Alias */) { + return false; + } + var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ + ? 225 /* FunctionDeclaration */ + : resolvedRequire.flags & 3 /* Variable */ + ? 223 /* VariableDeclaration */ + : 0 /* Unknown */; + if (targetDeclarationKind !== 0 /* Unknown */) { + var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + // function/variable declaration should be ambient + return ts.isInAmbientContext(decl); + } + return false; + } function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } @@ -34544,8 +36391,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 === 172 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 173 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34603,7 +36450,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; @@ -34615,7 +36462,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200 /* Block */) { + if (func.body.kind !== 204 /* 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 @@ -34705,7 +36552,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 218 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -34738,7 +36585,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { + func.kind === 184 /* FunctionExpression */ || func.kind === 185 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -34767,7 +36614,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 !== 204 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -34800,10 +36647,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 === 184 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -34844,14 +36691,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) { @@ -34867,7 +36714,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200 /* Block */) { + if (node.body.kind === 204 /* Block */) { checkSourceElement(node.body); } else { @@ -34914,11 +36761,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 === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* 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, @@ -34930,50 +36777,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 === 177 /* PropertyAccessExpression */ || expr.kind === 178 /* 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 === 237 /* 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 !== 177 /* PropertyAccessExpression */ && node.kind !== 178 /* 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) { @@ -34991,7 +36813,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)) { @@ -35027,7 +36849,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; } @@ -35041,7 +36863,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; } @@ -35051,7 +36873,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 1572864 /* UnionOrIntersection */) { + if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -35069,7 +36891,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -35079,7 +36901,7 @@ var ts; } return true; } - if (type.flags & 1048576 /* Intersection */) { + if (type.flags & 131072 /* Intersection */) { var types = type.types; for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { var t = types_17[_a]; @@ -35091,7 +36913,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (2588672 /* ObjectType */ | 2097152 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + return getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -35125,36 +36947,36 @@ var ts; if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */ | 340 /* NumberLike */ | 512 /* ESSymbol */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 /* ObjectType */ | 16384 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } 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 === 257 /* PropertyAssignment */ || property.kind === 258 /* 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 === 258 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -35163,7 +36985,12 @@ 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 if (property.kind === 259 /* SpreadAssignment */) { + if (property.expression.kind !== 70 /* Identifier */) { + error(property.expression, ts.Diagnostics.An_object_rest_element_must_be_an_identifier); } } else { @@ -35184,8 +37011,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 !== 198 /* OmittedExpression */) { + if (element.kind !== 196 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -35209,11 +37036,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 === 192 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -35226,7 +37053,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 258 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -35242,21 +37069,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 192 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 176 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171 /* ArrayLiteralExpression */) { + if (target.kind === 175 /* 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; @@ -35275,35 +37102,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 177 /* TaggedTemplateExpression */: - case 190 /* TemplateExpression */: + case 181 /* TaggedTemplateExpression */: + case 194 /* 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 184 /* FunctionExpression */: + case 197 /* ClassExpression */: + case 185 /* ArrowFunction */: + case 175 /* ArrayLiteralExpression */: + case 176 /* ObjectLiteralExpression */: + case 187 /* TypeOfExpression */: + case 201 /* NonNullExpression */: + case 247 /* JsxSelfClosingElement */: + case 246 /* JsxElement */: return true; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -35315,9 +37142,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 188 /* VoidExpression */: // Explicit opt-out + case 182 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 200 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35337,7 +37164,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 === 176 /* ObjectLiteralExpression */ || left.kind === 175 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -35520,9 +37347,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); } @@ -35550,7 +37375,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)) { @@ -35638,8 +37463,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 === 182 /* TypeAssertionExpression */ || node.kind === 200 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35671,7 +37496,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); @@ -35682,7 +37507,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); @@ -35712,7 +37537,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 { @@ -35724,9 +37549,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 === 177 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 178 /* 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); } @@ -35748,66 +37573,66 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: return checkCallExpression(node); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return checkClassExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: return checkAssertion(node); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: return checkNonNullAssertion(node); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return checkDeleteExpression(node); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return checkVoidExpression(node); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return checkAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 192 /* SpreadElementExpression */: - return checkSpreadElementExpression(node, contextualMapper); - case 194 /* OmittedExpression */: + case 196 /* SpreadElement */: + return checkSpreadExpression(node, contextualMapper); + case 198 /* OmittedExpression */: return undefinedWideningType; - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return checkYieldExpression(node); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return checkJsxExpression(node); - case 242 /* JsxElement */: + case 246 /* JsxElement */: return checkJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -35835,7 +37660,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); } } @@ -35846,7 +37671,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); } } @@ -35860,9 +37685,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 === 225 /* FunctionDeclaration */ || + node.kind === 184 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -35905,9 +37730,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; } @@ -35920,16 +37745,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 185 /* ArrowFunction */: + case 153 /* CallSignature */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 158 /* FunctionType */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + var parent_10 = node.parent; + if (node === parent_10.type) { + return parent_10; } } } @@ -35939,15 +37764,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 === 173 /* ArrayBindingPattern */ || + name_23.kind === 172 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } @@ -35955,12 +37780,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 === 225 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || + node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -35972,10 +37797,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; } @@ -36018,7 +37843,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)) { @@ -36032,13 +37857,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; } @@ -36064,7 +37889,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 */: @@ -36086,7 +37911,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223 /* InterfaceDeclaration */) { + if (node.kind === 227 /* 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 @@ -36106,7 +37931,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; } @@ -36114,7 +37939,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -36182,12 +38007,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 !== 184 /* FunctionExpression */ && n.kind !== 225 /* 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; } @@ -36217,7 +38042,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 === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -36241,7 +38066,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); @@ -36251,13 +38076,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 */)) { @@ -36273,11 +38098,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 !== 176 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36307,7 +38132,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); + typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -36360,6 +38185,17 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } + function checkMappedType(node) { + checkSourceElement(node.typeParameter); + checkSourceElement(node.type); + var type = getTypeFromMappedTypeNode(node); + var constraintType = getConstraintTypeFromMappedType(type); + var keyType = constraintType.flags & 16384 /* TypeParameter */ ? getApparentTypeOfTypeParameter(constraintType) : constraintType; + checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); } @@ -36367,9 +38203,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 !== 227 /* InterfaceDeclaration */ && + n.parent.kind !== 226 /* ClassDeclaration */ && + n.parent.kind !== 197 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36457,7 +38293,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 @@ -36496,7 +38332,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 === 227 /* 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 @@ -36507,7 +38343,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 === 225 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36629,16 +38465,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -36679,7 +38515,7 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (promise.flags & 131072 /* Reference */) { + if (getObjectFlags(promise) & 4 /* Reference */) { if (promise.target === tryGetGlobalPromiseType() || promise.target === getGlobalPromiseLikeType()) { return promise.typeArguments[0]; @@ -36723,7 +38559,7 @@ var ts; function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); function checkAwaitedTypeWorker(type) { - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { var types = []; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -36802,56 +38638,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 @@ -36876,39 +38675,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) { @@ -36921,22 +38737,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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]); @@ -36944,42 +38760,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 */ @@ -36998,21 +38791,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 226 /* 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; } } @@ -37034,7 +38833,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); @@ -37094,43 +38893,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 261 /* SourceFile */: + case 230 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 200 /* Block */: - case 228 /* CaseBlock */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 204 /* Block */: + case 232 /* CaseBlock */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* 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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* 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; } @@ -37139,43 +38938,57 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_1 = function (key) { + if (node.parent.kind !== 227 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 143 /* Parameter */) { - var parameter = local.valueDeclaration; + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { + var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { + !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return error(d.name || d, ts.Diagnostics._0_is_declared_but_never_used, local.name); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d.name || d, local.name); }); } } }; for (var key in node.locals) { - _loop_1(key); + _loop_3(key); } } } - function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 70 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; + function errorUnusedLocal(node, name) { + if (isIdentifierThatStartsWithUnderScore(node)) { + var declaration = ts.getRootDeclaration(node.parent); + if (declaration.kind === 223 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 212 /* ForInStatement */ || + declaration.parent.parent.kind === 213 /* ForOfStatement */)) { + return; + } + } + error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + } + function parameterNameStartsWithUnderscore(parameterName) { + return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); + } + function isIdentifierThatStartsWithUnderScore(node) { + return node.kind === 70 /* Identifier */ && node.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { 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 */) { @@ -37223,7 +39036,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 200 /* Block */) { + if (node.kind === 204 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -37246,12 +39059,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; } @@ -37260,7 +39073,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; } @@ -37317,12 +39130,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 230 /* 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 === 261 /* 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)); } @@ -37332,12 +39145,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 230 /* 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 === 261 /* 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)); } @@ -37372,7 +39185,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 === 223 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37382,24 +39195,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, 224 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 205 /* 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 === 204 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 231 /* ModuleBlock */ || + container.kind === 230 /* ModuleDeclaration */ || + container.kind === 261 /* 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); } } } @@ -37407,7 +39220,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); @@ -37418,7 +39231,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 173 /* PropertyAccessExpression */) { + if (n.kind === 177 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -37437,7 +39250,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) { @@ -37451,7 +39264,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; @@ -37478,24 +39291,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 === 174 /* 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_11 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_11); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + markPropertyAsReferenced(property); + if (parent_11.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -37503,14 +39317,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 !== 212 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37521,7 +39335,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 !== 212 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37541,10 +39355,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 === 223 /* VariableDeclaration */ || node.kind === 174 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37554,8 +39368,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 === 223 /* VariableDeclaration */) || + (left.kind === 223 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37585,7 +39399,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 === 176 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37606,7 +39420,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202 /* EmptyStatement */) { + if (node.thenStatement.kind === 206 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37626,12 +39440,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 === 224 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 224 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37654,14 +39468,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 === 224 /* 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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* 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. @@ -37669,8 +39483,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 @@ -37693,7 +39506,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 === 224 /* 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); @@ -37707,7 +39520,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 === 175 /* ArrayLiteralExpression */ || varExpr.kind === 176 /* 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 */)) { @@ -37715,13 +39528,13 @@ 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); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 2588672 /* ObjectType */ | 16384 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -37803,7 +39616,7 @@ var ts; if (!typeAsIterable.iterableElementType) { // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), // then just grab its type argument. - if ((type.flags & 131072 /* Reference */) && type.target === getGlobalIterableType()) { + if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableType()) { typeAsIterable.iterableElementType = type.typeArguments[0]; } else { @@ -37844,7 +39657,7 @@ var ts; if (!typeAsIterator.iteratorElementType) { // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), // then just grab its type argument. - if ((type.flags & 131072 /* Reference */) && type.target === getGlobalIteratorType()) { + if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIteratorType()) { typeAsIterator.iteratorElementType = type.typeArguments[0]; } else { @@ -37881,7 +39694,7 @@ var ts; } // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), // then just grab its type argument. - if ((type.flags & 131072 /* Reference */) && type.target === getGlobalIterableIteratorType()) { + if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableIteratorType()) { return type.typeArguments[0]; } return getElementTypeOfIterable(type, /*errorNode*/ undefined) || @@ -37909,8 +39722,12 @@ var ts; // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 524288 /* Union */) { - arrayType = getUnionType(ts.filter(arrayOrStringType.types, function (t) { return !(t.flags & 34 /* StringLike */); }), /*subtypeReduction*/ true); + if (arrayOrStringType.flags & 65536 /* Union */) { + var arrayTypes = arrayOrStringType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34 /* StringLike */); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); + } } else if (arrayOrStringType.flags & 34 /* StringLike */) { arrayType = neverType; @@ -37957,7 +39774,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; @@ -37984,12 +39801,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); } @@ -38010,7 +39827,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); } @@ -38019,7 +39836,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); } } @@ -38037,9 +39854,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 === 254 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -38051,15 +39869,21 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 253 /* 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); @@ -38076,7 +39900,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 219 /* 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; @@ -38106,22 +39930,20 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 70 /* Identifier */) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { + if (catchClause.variableDeclaration.type) { grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); } else if (catchClause.variableDeclaration.initializer) { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - var identifierName = catchClause.variableDeclaration.name.text; - var locals = catchClause.block.locals; - if (locals) { - var localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & 2 /* BlockScopedVariable */) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + var blockLocals = catchClause.block.locals; + if (blockLocals) { + for (var caughtName in catchClause.locals) { + var blockLocal = blockLocals[caughtName]; + if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); + } } } } @@ -38143,7 +39965,7 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (type.flags & 32768 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { + if (getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -38162,7 +39984,7 @@ var ts; if (stringIndexType && numberIndexType) { errorNode = declaredNumberIndexer || declaredStringIndexer; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (type.flags & 65536 /* Interface */)) { + if (!errorNode && (getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } @@ -38181,13 +40003,13 @@ 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) { errorNode = indexDeclaration; } - else if (containingType.flags & 65536 /* Interface */) { + else if (getObjectFlags(containingType) & 2 /* Interface */) { // for interfaces property and indexer might be inherited from different bases // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together @@ -38239,7 +40061,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 === 226 /* ClassDeclaration */ || declaration.kind === 227 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38302,7 +40124,9 @@ var ts; } checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType_1, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); 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)) { + if (baseType_1.symbol.valueDeclaration && + !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && + baseType_1.symbol.valueDeclaration.kind === 226 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -38331,8 +40155,8 @@ var ts; if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - var declaredType = (t.flags & 131072 /* Reference */) ? t.target : t; - if (declaredType.flags & (32768 /* Class */ | 65536 /* Interface */)) { + var declaredType = getObjectFlags(t) & 4 /* Reference */ ? t.target : t; + if (getObjectFlags(declaredType) & 3 /* ClassOrInterface */) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -38354,7 +40178,7 @@ var ts; if (declaration && ts.getModifierFlags(declaration) & 8 /* Private */) { var typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { - error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, node.expression.text); + error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); } } } @@ -38403,7 +40227,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 === 197 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38451,7 +40275,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) { @@ -38492,8 +40316,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 }; @@ -38523,7 +40347,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, 227 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38554,6 +40378,7 @@ var ts; // Grammar checking checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } function computeEnumMemberValues(node) { @@ -38570,7 +40395,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); } @@ -38629,7 +40454,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -38640,7 +40465,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38665,11 +40490,11 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: + case 177 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -38682,7 +40507,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174 /* ElementAccessExpression */) { + if (e.kind === 178 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38700,7 +40525,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 173 /* PropertyAccessExpression */) { + else if (current.kind === 177 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -38772,7 +40597,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 !== 229 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -38795,8 +40620,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 === 226 /* ClassDeclaration */ || + (declaration.kind === 225 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -38860,7 +40685,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, 226 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -38911,26 +40736,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201 /* VariableStatement */: + case 205 /* 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 240 /* ExportAssignment */: + case 241 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230 /* ImportEqualsDeclaration */: - case 231 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 235 /* 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 174 /* BindingElement */: + case 223 /* 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); @@ -38938,12 +40763,12 @@ var ts; break; } // fallthrough - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 221 /* FunctionDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 225 /* FunctionDeclaration */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 228 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -38966,12 +40791,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 177 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -38984,9 +40809,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 === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 241 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -39019,7 +40844,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 === 243 /* 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)); @@ -39047,7 +40872,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 237 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -39104,8 +40929,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 === 231 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 261 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -39119,7 +40944,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 === 261 /* SourceFile */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 230 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -39145,8 +40970,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 === 261 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 230 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -39221,7 +41046,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || + return (declaration.kind !== 225 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -39234,118 +41059,123 @@ 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 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 225 /* 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 170 /* MappedType */: + return checkMappedType(node); + case 225 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 204 /* Block */: + case 231 /* ModuleBlock */: return checkBlock(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return checkVariableStatement(node); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return checkExpressionStatement(node); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return checkIfStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return checkDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return checkWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return checkForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return checkForInStatement(node); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return checkForOfStatement(node); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 214 /* ContinueStatement */: + case 215 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return checkReturnStatement(node); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return checkWithStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return checkSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return checkLabeledStatement(node); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return checkThrowStatement(node); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return checkTryStatement(node); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 170 /* BindingElement */: + case 174 /* BindingElement */: return checkBindingElement(node); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return checkClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return checkImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return checkExportDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return checkExportAssignment(node); - case 202 /* EmptyStatement */: + case 206 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 218 /* DebuggerStatement */: + case 222 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 240 /* MissingDeclaration */: + case 244 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39367,17 +41197,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 184 /* FunctionExpression */: + case 185 /* 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 197 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39439,9 +41269,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(); } @@ -39458,7 +41308,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 === 217 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39481,25 +41331,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 193 /* ClassExpression */: + case 197 /* 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 226 /* ClassDeclaration */: + case 227 /* 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. @@ -39508,7 +41358,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39557,28 +41407,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 229 /* 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 === 272 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 177 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 199 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39595,13 +41445,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 === 234 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 240 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39613,7 +41463,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 === 177 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39625,13 +41475,13 @@ var ts; default: } } - if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 240 /* 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 !== 177 /* 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, 234 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -39641,7 +41491,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 === 199 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39665,14 +41515,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 173 /* PropertyAccessExpression */) { + else if (entityName.kind === 177 /* 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); @@ -39681,20 +41531,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 === 272 /* 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 === 250 /* 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 === 261 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -39712,8 +41562,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 === 174 /* BindingElement */ && + node.parent.parent.kind === 172 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -39724,8 +41574,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 177 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -39739,12 +41589,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; @@ -39752,7 +41602,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 === 235 /* ImportDeclaration */ || node.parent.kind === 241 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -39762,7 +41612,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -39779,7 +41629,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 === 258 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -39841,28 +41691,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 === 176 /* ObjectLiteralExpression */ || expr.kind === 175 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 209 /* ForOfStatement */) { + if (expr.parent.kind === 213 /* 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 === 192 /* 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 === 257 /* 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 === 175 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -39912,9 +41762,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); } @@ -39922,6 +41772,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) { @@ -39994,7 +41848,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 === 261 /* 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. @@ -40051,7 +41905,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 === 204 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -40097,16 +41951,16 @@ var ts; return true; } switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportClause */: + case 237 /* NamespaceImport */: + case 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -40116,7 +41970,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 !== 261 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -40182,7 +42036,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255 /* EnumMember */) { + if (node.kind === 260 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -40195,7 +42049,7 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 2588672 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. @@ -40283,9 +42137,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_12 = reference.parent; + if (ts.isDeclaration(parent_12) && reference === parent_12.name) { + location = getDeclarationContainer(parent_12); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -40305,7 +42159,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 16777216 /* FreshLiteral */); + return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 1048576 /* FreshLiteral */); } return false; } @@ -40359,7 +42213,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) { @@ -40370,7 +42225,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 === 177 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40396,6 +42251,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; @@ -40409,15 +42268,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_13 = getParentOfSymbol(current); + if (parent_13) { + current = parent_13; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 261 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -40437,7 +42296,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 261 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -40470,7 +42329,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) { @@ -40549,9 +42408,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) { @@ -40587,7 +42450,7 @@ var ts; // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(2097152 /* Anonymous */); + var thenableType = createObjectType(16 /* Anonymous */); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; @@ -40600,14 +42463,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); @@ -40624,17 +42487,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 !== 229 /* EnumDeclaration */ && node.parent.kind === 226 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -40660,7 +42523,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 === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -40683,10 +42546,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 === 231 /* ModuleBlock */ || node.parent.kind === 261 /* 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 */) { @@ -40695,11 +42558,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); } @@ -40719,10 +42582,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 === 226 /* 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 */; @@ -40734,13 +42597,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 === 226 /* 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 === 231 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -40750,14 +42613,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 !== 226 /* 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 === 226 /* 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 */) { @@ -40776,7 +42639,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 */; @@ -40784,7 +42647,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"); } @@ -40799,13 +42662,13 @@ var ts; } return; } - else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 235 /* ImportDeclaration */ || node.kind === 234 /* 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 */) { @@ -40825,37 +42688,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 230 /* ModuleDeclaration */: + case 235 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 241 /* ExportDeclaration */: + case 240 /* ExportAssignment */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 144 /* Parameter */: return false; default: - if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { return false; } switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 223 /* InterfaceDeclaration */: - case 201 /* VariableStatement */: - case 224 /* TypeAliasDeclaration */: + case 227 /* InterfaceDeclaration */: + case 205 /* VariableStatement */: + case 228 /* TypeAliasDeclaration */: return true; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -40868,10 +42731,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -40934,7 +42797,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 185 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -40969,7 +42832,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) { @@ -40997,7 +42860,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 === 198 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -41070,19 +42933,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 === 192 /* 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 === 225 /* FunctionDeclaration */ || + node.kind === 184 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -41107,12 +42970,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 === 259 /* 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 === 258 /* 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); @@ -41121,7 +42987,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)); } } @@ -41135,27 +43001,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 === 257 /* PropertyAssignment */ || prop.kind === 258 /* 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; } @@ -41165,18 +43031,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); } } } @@ -41185,19 +43051,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 === 251 /* 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 === 252 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -41206,7 +43072,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 224 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -41221,20 +43087,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 212 /* 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 === 212 /* 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 === 212 /* 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); @@ -41258,11 +43124,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); } @@ -41285,10 +43151,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); } } @@ -41303,7 +43169,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (node.parent.kind === 176 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -41324,10 +43190,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 === 227 /* 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); } } @@ -41338,11 +43204,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215 /* LabeledStatement */: + case 219 /* 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 === 214 /* 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); @@ -41350,8 +43216,8 @@ var ts; return false; } break; - case 214 /* SwitchStatement */: - if (node.kind === 211 /* BreakStatement */ && !node.label) { + case 218 /* SwitchStatement */: + if (node.kind === 215 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41366,13 +43232,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 /* BreakStatement */ + var message = node.kind === 215 /* 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 === 215 /* 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); @@ -41382,24 +43248,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 === 173 /* ArrayBindingPattern */ || node.name.kind === 172 /* 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 === 190 /* 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 !== 212 /* ForInStatement */ && node.parent.parent.kind !== 213 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41464,15 +43330,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 208 /* IfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 217 /* WithStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: return false; - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41527,7 +43393,7 @@ var ts; return true; } } - else if (node.parent.kind === 223 /* InterfaceDeclaration */) { + else if (node.parent.kind === 227 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41535,7 +43401,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; } @@ -41560,13 +43426,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 === 227 /* InterfaceDeclaration */ || + node.kind === 228 /* TypeAliasDeclaration */ || + node.kind === 235 /* ImportDeclaration */ || + node.kind === 234 /* ImportEqualsDeclaration */ || + node.kind === 241 /* ExportDeclaration */ || + node.kind === 240 /* ExportAssignment */ || + node.kind === 233 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41575,7 +43441,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 === 205 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41601,7 +43467,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 === 204 /* Block */ || node.parent.kind === 231 /* ModuleBlock */ || node.parent.kind === 261 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41661,49 +43527,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[182 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196 /* AsExpression */] = [ + _a[200 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197 /* NonNullExpression */] = [ + _a[201 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225 /* EnumDeclaration */] = [ + _a[229 /* 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[230 /* 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[231 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[230 /* ImportEqualsDeclaration */] = [ + _a[234 /* 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[245 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255 /* EnumMember */] = [ + _a[260 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -41726,47 +43592,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 <= 171 /* 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 203 /* SemicolonClassElement */: + case 206 /* EmptyStatement */: + case 198 /* OmittedExpression */: + case 222 /* DebuggerStatement */: + case 292 /* 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); @@ -41775,12 +43641,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); @@ -41788,7 +43654,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); @@ -41796,45 +43662,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 170 /* BindingElement */: + case 174 /* 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 175 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175 /* CallExpression */: + case 179 /* 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 180 /* 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 181 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -41842,119 +43708,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181 /* ArrowFunction */: + case 185 /* 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 183 /* ParenthesizedExpression */: + case 186 /* DeleteExpression */: + case 187 /* TypeOfExpression */: + case 188 /* VoidExpression */: + case 189 /* AwaitExpression */: + case 195 /* YieldExpression */: + case 196 /* SpreadElement */: + case 201 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193 /* ClassExpression */: + case 197 /* 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 199 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 200 /* Block */: + case 204 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 204 /* IfStatement */: + case 208 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205 /* DoStatement */: + case 209 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206 /* WhileStatement */: - case 213 /* WithStatement */: + case 210 /* WhileStatement */: + case 217 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForStatement */: + case 211 /* 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 212 /* ForInStatement */: + case 213 /* 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 216 /* ReturnStatement */: + case 220 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217 /* TryStatement */: + case 221 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41963,7 +43829,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41971,94 +43837,97 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 231 /* ImportDeclaration */: + case 235 /* 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 236 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 239 /* ImportSpecifier */: + case 243 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236 /* ExportAssignment */: + case 240 /* 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 241 /* 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 246 /* 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 247 /* JsxSelfClosingElement */: + case 248 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: result = reduceNode(node.tagName, f, result); break; - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: result = reduceNode(node.expression, f, result); break; - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: result = reduceNode(node.expression, f, result); break; // Clauses - case 249 /* CaseClause */: + case 253 /* CaseClause */: result = reduceNode(node.expression, f, result); // fall-through - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: result = ts.reduceLeft(node.statements, f, result); break; - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: result = ts.reduceLeft(node.types, f, result); break; - case 252 /* CatchClause */: + case 256 /* CatchClause */: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; // Property assignments - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; + case 259 /* SpreadAssignment */: + result = reduceNode(node.expression, f, result); + break; // Top-level nodes - case 256 /* SourceFile */: + case 261 /* SourceFile */: result = ts.reduceLeft(node.statements, f, result); break; - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, f, result); break; default: @@ -42083,6 +43952,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -42131,6 +44001,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) { @@ -42169,192 +44040,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 <= 171 /* LiteralType */)) { return node; } switch (node.kind) { - case 199 /* SemicolonClassElement */: - case 202 /* EmptyStatement */: - case 194 /* OmittedExpression */: - case 218 /* DebuggerStatement */: + case 203 /* SemicolonClassElement */: + case 206 /* EmptyStatement */: + case 198 /* OmittedExpression */: + case 222 /* 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 172 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169 /* ArrayBindingPattern */: + case 173 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170 /* BindingElement */: + case 174 /* 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 175 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175 /* CallExpression */: + case 179 /* 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 180 /* 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 181 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180 /* FunctionExpression */: + case 184 /* 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 185 /* 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 186 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189 /* ConditionalExpression */: + case 193 /* 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 194 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* SpreadElementExpression */: + case 196 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ClassExpression */: + case 197 /* 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 199 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 200 /* Block */: + case 204 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* IfStatement */: + case 208 /* 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 209 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 207 /* ForStatement */: + case 211 /* 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 212 /* 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 213 /* 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 214 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* TryStatement */: + case 221 /* 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 223 /* 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 224 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 221 /* FunctionDeclaration */: + case 225 /* 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 226 /* 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 232 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 231 /* ImportDeclaration */: + case 235 /* 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 236 /* 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 237 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 234 /* NamedImports */: + case 238 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 235 /* ImportSpecifier */: + case 239 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 236 /* ExportAssignment */: + case 240 /* 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 241 /* 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 242 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 242 /* JsxElement */: + case 246 /* 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 247 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 249 /* CaseClause */: + case 253 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 259 /* SpreadAssignment */: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 256 /* SourceFile */: + case 261 /* 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 293 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -42436,7 +44309,7 @@ var ts; return 0 /* None */; } else if (node.transformFlags & 536870912 /* HasComputedFlags */) { - return node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind); + return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind); } else { var subtreeFlags = aggregateTransformFlagsForSubtree(node); @@ -42462,75 +44335,17 @@ var ts; function aggregateTransformFlagsForChildNode(transformFlags, child) { return transformFlags | aggregateTransformFlagsForNode(child); } - /** - * Gets the transform flags to exclude when unioning the transform flags of a subtree. - * - * NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`. - * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather - * than calling this function. - */ - function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* 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 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: - case 133 /* StringKeyword */: - case 121 /* BooleanKeyword */: - case 134 /* 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 */: - return -3 /* TypeExcludes */; - case 172 /* ObjectLiteralExpression */: - return 539110741 /* ObjectLiteralExcludes */; - default: - return 536874325 /* NodeExcludes */; - } - } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function () { }; + : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function () { }; + : ts.noop; Debug.assertNode = Debug.shouldAssert(1 /* Normal */) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function () { }; + : ts.noop; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -42561,7 +44376,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)) { @@ -42592,7 +44407,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); } @@ -42612,6 +44427,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; /** @@ -42621,9 +44439,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); @@ -42638,6 +44456,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; /** @@ -42647,10 +44468,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) { @@ -42682,6 +44503,9 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; /** @@ -42689,36 +44513,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); } @@ -42750,17 +44578,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 176 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171 /* ArrayLiteralExpression */) { + else if (target.kind === 175 /* 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) { @@ -42771,30 +44599,96 @@ 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 === 257 /* PropertyAssignment */ || p.kind === 258 /* ShorthandPropertyAssignment */) { + if (!transformRest || + p.transformFlags & 8388608 /* ContainsSpreadExpression */ || + (p.kind === 257 /* PropertyAssignment */ && p.initializer.transformFlags & 8388608 /* ContainsSpreadExpression */)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 258 /* 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 === 259 /* SpreadAssignment */ && + 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 === 198 /* 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 !== 198 /* 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 !== 196 /* SpreadElement */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -42803,10 +44697,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; } @@ -42815,9 +44729,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 @@ -42825,29 +44741,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 === 173 /* 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) { @@ -42938,15 +44923,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(177 /* PropertyAccessExpression */); + context.enableSubstitution(178 /* 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. @@ -43007,7 +44992,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 261 /* SourceFile */) { return visitSourceFile(node); } else if (node.transformFlags & 1 /* TypeScript */) { @@ -43035,13 +45020,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return visitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -43061,11 +45046,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 === 241 /* ExportDeclaration */ || + node.kind === 235 /* ImportDeclaration */ || + node.kind === 236 /* ImportClause */ || + (node.kind === 234 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 245 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -43095,25 +45080,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 203 /* 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. * @@ -43136,45 +45130,48 @@ 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 /* MappedType */: + case 171 /* 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 228 /* 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 227 /* 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 226 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43185,7 +45182,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43196,35 +45193,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 195 /* ExpressionWithTypeArguments */: + case 199 /* 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 225 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 185 /* 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: @@ -43234,33 +45231,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 182 /* TypeAssertionExpression */: + case 200 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return visitNewExpression(node); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -43275,15 +45272,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 256 /* SourceFile */: - case 228 /* CaseBlock */: - case 227 /* ModuleBlock */: - case 200 /* Block */: + case 261 /* SourceFile */: + case 232 /* CaseBlock */: + case 231 /* ModuleBlock */: + case 204 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222 /* ClassDeclaration */: - case 221 /* FunctionDeclaration */: + case 226 /* ClassDeclaration */: + case 225 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -43294,13 +45291,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(); @@ -43313,10 +45314,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; } @@ -43360,7 +45361,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 @@ -43369,38 +45369,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. @@ -43409,26 +45393,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. // @@ -43463,20 +45475,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 @@ -43505,59 +45517,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. @@ -43620,7 +45604,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. @@ -43740,7 +45724,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -43813,7 +45797,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; } @@ -43948,12 +45932,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; @@ -44105,11 +46089,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; } @@ -44118,8 +46102,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)); } @@ -44129,33 +46113,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. @@ -44177,7 +46147,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); @@ -44202,13 +46172,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))); } } } @@ -44216,16 +46186,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))); } } } @@ -44238,10 +46208,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. @@ -44251,7 +46221,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. @@ -44262,11 +46232,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 === 226 /* ClassDeclaration */ + || kind === 197 /* ClassExpression */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -44275,15 +46245,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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -44296,10 +46266,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 { @@ -44375,20 +46345,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 171 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -44402,16 +46372,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; @@ -44440,10 +46410,13 @@ var ts; } } // Fallthrough - case 159 /* TypeQuery */: - case 160 /* TypeLiteral */: + case 160 /* TypeQuery */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* MappedType */: + case 161 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44500,15 +46473,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); } } @@ -44641,7 +46614,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); @@ -44675,14 +46648,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; } /** @@ -44699,13 +46672,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; } /** @@ -44723,7 +46696,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); @@ -44747,7 +46720,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); @@ -44760,7 +46733,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); @@ -44820,7 +46793,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, @@ -44857,7 +46830,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), @@ -44923,21 +46896,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. * @@ -44956,9 +46914,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 */; @@ -44969,7 +46925,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"; // ... @@ -44978,16 +46945,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; } /** @@ -45049,9 +47016,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 @@ -45077,55 +47050,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 === 229 /* 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. @@ -45147,9 +47129,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 */; @@ -45160,13 +47140,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); } @@ -45177,13 +47159,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; } /** @@ -45203,7 +47188,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227 /* ModuleBlock */) { + if (body.kind === 231 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -45249,13 +47234,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 !== 231 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 230 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -45296,7 +47281,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 233 /* NamespaceImport */) { + if (node.kind === 237 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -45403,9 +47388,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 { @@ -45454,38 +47439,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. @@ -45503,67 +47470,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() { @@ -45588,20 +47513,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(258 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(226 /* ModuleDeclaration */); + context.enableEmitNotification(230 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 230 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 229 /* 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. */ @@ -45619,9 +47545,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); @@ -45635,16 +47560,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; @@ -45653,9 +47578,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -45689,13 +47614,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 !== 261 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 230 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 229 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45774,11 +47699,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242 /* JsxElement */: + case 246 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -45789,11 +47714,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return visitJsxExpression(node); - case 242 /* JsxElement */: + case 246 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -45830,7 +47755,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); } @@ -45852,7 +47777,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 === 252 /* JsxExpression */) { return visitJsxExpression(node); } else { @@ -45934,16 +47859,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242 /* JsxElement */) { + if (node.kind === 246 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_31 = node.tagName; - if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { - return ts.createLiteral(name_31.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_31); + return ts.createExpressionFromEntityName(name_34); } } } @@ -46228,6 +48153,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 176 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 192 /* BinaryExpression */: + return visitBinaryExpression(node); + case 223 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 213 /* ForOfStatement */: + return visitForOfStatement(node); + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: + return node; + case 225 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 184 /* FunctionExpression */: + return visitFunctionExpression(node); + case 185 /* 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 === 259 /* 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 === 257 /* 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 !== 176 /* 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 === 172 /* ObjectBindingPattern */ && + !!(declaration.name.transformFlags & 8388608 /* ContainsSpreadExpression */); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 176 /* 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 === 172 /* 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; @@ -46272,10 +48423,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; @@ -46285,19 +48436,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 185 /* AwaitExpression */: + case 189 /* 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 225 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -46418,9 +48569,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 === 185 /* 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 @@ -46470,12 +48622,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; @@ -46485,24 +48639,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(179 /* CallExpression */); + context.enableSubstitution(177 /* PropertyAccessExpression */); + context.enableSubstitution(178 /* 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(226 /* 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 177 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -46546,11 +48700,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 === 226 /* ClassDeclaration */ + || kind === 150 /* Constructor */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Hook for node emit. @@ -46616,10 +48770,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 { @@ -46628,7 +48782,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -46742,6 +48896,7 @@ var ts; var enclosingFunction; var enclosingNonArrowFunction; var enclosingNonAsyncFunctionBody; + var isInConstructorWithCapturedSuper; /** * Used to track if we are emitting body of the converted loop */ @@ -46779,12 +48934,15 @@ var ts; var savedCurrentParent = currentParent; var savedCurrentNode = currentNode; var savedConvertedLoopState = convertedLoopState; + var savedIsInConstructorWithCapturedSuper = isInConstructorWithCapturedSuper; if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy + // don't treat content of nodes that start new lexical environment as part of converted loop copy or constructor body + isInConstructorWithCapturedSuper = false; convertedLoopState = undefined; } onBeforeVisitNode(node); var visited = f(node); + isInConstructorWithCapturedSuper = savedIsInConstructorWithCapturedSuper; convertedLoopState = savedConvertedLoopState; enclosingFunction = savedEnclosingFunction; enclosingNonArrowFunction = savedEnclosingNonArrowFunction; @@ -46796,16 +48954,28 @@ var ts; currentNode = savedCurrentNode; return visited; } + function returnCapturedThis(node) { + return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); + } + function isReturnVoidStatementInConstructorWithCapturedSuper(node) { + return isInConstructorWithCapturedSuper && node.kind === 216 /* ReturnStatement */ && !node.expression; + } function shouldCheckNode(node) { - return (node.transformFlags & 256 /* ES2015 */) !== 0 || - node.kind === 215 /* LabeledStatement */ || + return (node.transformFlags & 1024 /* ES2015 */) !== 0 || + node.kind === 219 /* LabeledStatement */ || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { - if (shouldCheckNode(node)) { + if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { + return returnCapturedThis(node); + } + else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 /* ContainsES2015 */) { + 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 return ts.visitEachChild(node, visitor, context); } else { @@ -46824,14 +48994,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: + node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitVariableStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return visitSwitchStatement(node); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: return visitBreakOrContinueStatement(node); case 98 /* ThisKeyword */: return visitThisKeyword(node); @@ -46843,75 +49014,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 226 /* ClassDeclaration */: return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return visitClassExpression(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return visitParameter(node); - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return visitArrowFunction(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return visitLabeledStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return visitWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return visitForInStatement(node); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return visitForOfStatement(node); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return visitExpressionStatement(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 254 /* ShorthandPropertyAssignment */: + case 256 /* CatchClause */: + return visitCatchClause(node); + case 258 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return visitNewExpression(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 188 /* BinaryExpression */: + case 192 /* 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 181 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return visitTemplateExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return visitYieldExpression(node); case 96 /* SuperKeyword */: return visitSuperKeyword(); - case 191 /* YieldExpression */: + case 195 /* 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 261 /* SourceFile */: return visitSourceFileNode(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -46926,7 +49099,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181 /* ArrowFunction */) { + if (currentNode.kind !== 185 /* ArrowFunction */) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { enclosingNonAsyncFunctionBody = currentNode; @@ -46937,14 +49110,14 @@ var ts; // variable statements, variable declarations, binding elements, and binding // patterns. switch (currentNode.kind) { - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: enclosingVariableStatement = currentNode; break; - case 220 /* VariableDeclarationList */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 224 /* VariableDeclarationList */: + case 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: break; default: enclosingVariableStatement = undefined; @@ -46973,7 +49146,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + if (enclosingFunction && enclosingFunction.kind === 185 /* ArrowFunction */) { // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -46998,13 +49171,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 === 215 /* 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 === 215 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -47015,7 +49188,7 @@ var ts; } } else { - if (node.kind === 211 /* BreakStatement */) { + if (node.kind === 215 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -47059,33 +49232,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. @@ -47140,7 +49309,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 @@ -47175,7 +49344,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); @@ -47199,7 +49368,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)); } } @@ -47216,7 +49385,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); @@ -47267,8 +49436,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); @@ -47277,7 +49446,10 @@ var ts; statementOffset++; } if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); + var body = saveStateAndInvoke(constructor, function (constructor) { + isInConstructorWithCapturedSuper = superCaptureStatus === 1 /* ReplaceSuperCapture */; + return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); + }); ts.addRange(statements, body); } // Return `_this` unless we're sure enough that it would be pointless to add a return statement. @@ -47304,17 +49476,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 212 /* ReturnStatement */) { + if (statement.kind === 216 /* ReturnStatement */) { return true; } - else if (statement.kind === 204 /* IfStatement */) { + else if (statement.kind === 208 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200 /* Block */) { + else if (statement.kind === 204 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -47331,7 +49503,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 */; } @@ -47346,7 +49518,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 */; } @@ -47372,7 +49544,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 === 207 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -47383,7 +49555,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 */; @@ -47409,14 +49581,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); @@ -47425,158 +49607,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_32 = 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_32)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_32, 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. @@ -47588,20 +49618,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 203 /* 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: @@ -47707,7 +49737,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); @@ -47731,7 +49761,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); } @@ -47744,91 +49774,17 @@ var ts; */ function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181 /* ArrowFunction */) { + if (node.kind !== 185 /* 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. * @@ -47837,9 +49793,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 183 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -47855,10 +49811,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 183 /* ParenthesizedExpression */: return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); } @@ -47887,7 +49843,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)); @@ -47920,7 +49876,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 @@ -47986,8 +49942,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && enclosingBlockScopeContainer.kind !== 212 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 213 /* ForOfStatement */ && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -48068,118 +50024,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. @@ -48195,8 +50040,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; } @@ -48262,11 +50107,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 224 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -48315,7 +50160,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 */; @@ -48324,14 +50169,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 @@ -48413,7 +50258,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 /* LabeledStatement */ + statements.push(currentParent.kind === 219 /* LabeledStatement */ ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -48519,7 +50364,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 }); @@ -48541,20 +50386,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 257 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -48608,6 +50453,19 @@ var ts; } return expression; } + function visitCatchClause(node) { + ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); + var temp = ts.createTempVariable(undefined); + var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + var vars = ts.flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + var list = ts.createVariableDeclarationList(vars, /*location*/ node.variableDeclaration, /*flags*/ node.variableDeclaration.flags); + var destructure = ts.createVariableStatement(undefined, list); + return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + function addStatementToStartOfBlock(block, statement) { + var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); + return ts.updateBlock(block, [statement].concat(transformedStatements)); + } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a * PropertyAssignment. @@ -48670,7 +50528,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) @@ -48716,7 +50574,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) // @@ -48727,7 +50585,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. @@ -48742,36 +50600,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 !== 175 /* 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); } /** @@ -48928,7 +50786,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 175 /* CallExpression */ + && currentParent.kind !== 179 /* CallExpression */ ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -48937,7 +50795,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); @@ -48976,21 +50834,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(185 /* ArrowFunction */); + context.enableEmitNotification(184 /* FunctionExpression */); + context.enableEmitNotification(225 /* 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); @@ -49025,10 +50882,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 174 /* BindingElement */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 223 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -49075,44 +50932,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_33 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_33, emitFlags); - } - return name_33; - } - 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) { @@ -49124,11 +50945,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 !== 207 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 179 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -49136,7 +50957,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 !== 196 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -49378,7 +51199,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; @@ -49398,10 +51219,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 { @@ -49415,13 +51236,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205 /* DoStatement */: + case 209 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return visitWhileStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return visitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -49434,30 +51255,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return visitFunctionExpression(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return visitVariableStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return visitForInStatement(node); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return visitBreakStatement(node); - case 210 /* ContinueStatement */: + case 214 /* ContinueStatement */: return visitContinueStatement(node); - case 212 /* ReturnStatement */: + case 216 /* 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 { @@ -49472,21 +51293,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return visitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return visitConditionalExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return visitYieldExpression(node); - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -49499,9 +51320,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -49662,7 +51483,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; } @@ -49730,7 +51551,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -49742,7 +51563,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 178 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -50111,35 +51932,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200 /* Block */: + case 204 /* Block */: return transformAndEmitBlock(node); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return transformAndEmitIfStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return transformAndEmitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return transformAndEmitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 210 /* ContinueStatement */: + case 214 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return transformAndEmitWithStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -50559,7 +52380,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 === 254 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -50572,7 +52393,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 === 253 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -50703,7 +52524,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; @@ -50733,9 +52554,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_34) { - var clone_8 = ts.getMutableClone(name_34); + 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; @@ -51137,7 +52958,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]; } @@ -51146,7 +52967,7 @@ var ts; } return expression; } - return ts.createNode(194 /* OmittedExpression */); + return ts.createOmittedExpression(); } /** * Creates a numeric literal for the provided instruction. @@ -51331,7 +53152,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 */) @@ -51708,1909 +53529,6 @@ var ts; ts.transformGenerators = transformGenerators; var _a; })(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_35 = names_1[_i]; - addExportMemberAssignments(statements, name_35); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_36 = node.name; - if (ts.isIdentifier(name_36)) { - names.push(name_36); - } - } - 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_37 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), - /*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_1 = externalImports; _b < externalImports_1.length; _b++) { - var importNode = externalImports_1[_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*/ -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_2 = externalImports; _i < externalImports_2.length; _i++) { - var externalImport = externalImports_2[_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_3 = externalImports; _b < externalImports_3.length; _b++) { - var externalImport = externalImports_3[_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_38 = 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_38, - /*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_38); - } - 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_39 = 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_39); - } - return [ - node, - createExportStatement(name_39, name_39) - ]; - } - 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 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*/ @@ -53624,8 +53542,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(253 /* PropertyAssignment */); + context.enableSubstitution(177 /* PropertyAccessExpression */); + context.enableSubstitution(257 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -53690,9 +53608,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 234 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 240 /* 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(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(261 /* 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 === 241 /* 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 !== 241 /* 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 235 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 234 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 241 /* 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 235 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 234 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 241 /* ExportDeclaration */: + // ExportDeclarations are elided as they are handled via + // `appendExportsOfDeclaration`. + return undefined; + case 240 /* 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 === 261 /* 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 === 205 /* 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 237 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238 /* 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 205 /* VariableStatement */: + return visitVariableStatement(node); + case 225 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 226 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 211 /* ForStatement */: + return visitForStatement(node); + case 212 /* ForInStatement */: + return visitForInStatement(node); + case 213 /* ForOfStatement */: + return visitForOfStatement(node); + case 209 /* DoStatement */: + return visitDoStatement(node); + case 210 /* WhileStatement */: + return visitWhileStatement(node); + case 219 /* LabeledStatement */: + return visitLabeledStatement(node); + case 217 /* WithStatement */: + return visitWithStatement(node); + case 218 /* SwitchStatement */: + return visitSwitchStatement(node); + case 232 /* CaseBlock */: + return visitCaseBlock(node); + case 253 /* CaseClause */: + return visitCaseClause(node); + case 254 /* DefaultClause */: + return visitDefaultClause(node); + case 221 /* TryStatement */: + return visitTryStatement(node); + case 256 /* CatchClause */: + return visitCatchClause(node); + case 204 /* Block */: + return visitBlock(node); + case 294 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 295 /* 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 === 192 /* 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 === 261 /* 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 === 261 /* 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 192 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 190 /* PrefixUnaryExpression */: + case 191 /* 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 === 191 /* 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 === 191 /* 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 === 261 /* 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(192 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(190 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(191 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(258 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(261 /* 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 235 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 234 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 241 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 240 /* ExportAssignment */: + return visitExportAssignment(node); + case 205 /* VariableStatement */: + return visitVariableStatement(node); + case 225 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 226 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 294 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 295 /* 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 === 205 /* 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 237 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 238 /* 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 === 261 /* 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 192 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 191 /* PostfixUnaryExpression */: + case 190 /* 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 === 261 /* 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 === 191 /* 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 = {})); /// /// /// +/// /// /// /// @@ -53723,10 +56084,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); } @@ -53737,6 +56100,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); } @@ -53754,7 +56120,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289 /* Count */); + var enabledSyntaxKindFeatures = new Array(296 /* Count */); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -54154,7 +56520,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 !== 292 /* NotEmittedStatement */ && (emitFlags & 512 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -54167,7 +56533,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 /* NotEmittedStatement */ + if (node.kind !== 292 /* NotEmittedStatement */ && (emitFlags & 1024 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -54346,7 +56712,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 292 /* 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 @@ -54365,7 +56731,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 === 224 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -54619,7 +56985,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? ts.noop : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -54675,7 +57041,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 === 235 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -54749,10 +57115,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219 /* VariableDeclaration */) { + if (declaration.kind === 223 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { + else if (declaration.kind === 238 /* NamedImports */ || declaration.kind === 239 /* ImportSpecifier */ || declaration.kind === 236 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -54770,7 +57136,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 === 235 /* 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; @@ -54780,12 +57146,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 230 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -54903,43 +57269,49 @@ 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 171 /* LiteralType */: return writeTextOfNode(currentText, type); - case 195 /* ExpressionWithTypeArguments */: + case 199 /* 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 emitIndexedAccessType(type); + case 170 /* MappedType */: + return emitMappedType(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) { @@ -54947,8 +57319,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); @@ -54957,14 +57329,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 === 234 /* 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 === 177 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -55010,6 +57382,42 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitIndexedAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } + function emitMappedType(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + writeEntityName(node.typeParameter.name); + write(" in "); + emitType(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emitType(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + enclosingDeclaration = prevEnclosingDeclaration; + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -55043,9 +57451,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; } } } @@ -55092,10 +57500,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 /* ImportEqualsDeclaration */ || - (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 234 /* ImportEqualsDeclaration */ || + (node.parent.kind === 261 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 261 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -55105,7 +57513,7 @@ var ts; }); } else { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 235 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -55123,23 +57531,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return writeVariableStatement(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return writeClassDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -55147,7 +57555,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 === 261 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -55156,7 +57564,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 227 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -55208,7 +57616,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 237 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -55232,7 +57640,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 === 237 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -55253,13 +57661,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 !== 230 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 230 /* ImportEqualsDeclaration */) { + if (parent.kind === 234 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226 /* ModuleDeclaration */) { + else if (parent.kind === 230 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -55329,7 +57737,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227 /* ModuleBlock */) { + while (node.body && node.body.kind !== 231 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -55399,7 +57807,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) { @@ -55410,15 +57818,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 { @@ -55429,31 +57837,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 226 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223 /* InterfaceDeclaration */: + case 227 /* 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 === 226 /* 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 225 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -55491,7 +57899,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 === 226 /* 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 : @@ -55575,7 +57983,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 !== 223 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -55586,11 +57994,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)) { @@ -55603,14 +58011,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 223 /* 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 ? @@ -55619,7 +58027,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 === 226 /* 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 : @@ -55651,7 +58059,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 !== 198 /* OmittedExpression */) { elements.push(element); } } @@ -55721,7 +58129,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; @@ -55734,7 +58142,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 @@ -55743,7 +58151,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 ? @@ -55793,17 +58201,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 === 225 /* 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 === 225 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149 /* Constructor */) { + else if (node.kind === 150 /* Constructor */) { write("constructor"); } else { @@ -55823,17 +58231,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 @@ -55848,22 +58256,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; @@ -55877,26 +58285,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 */ ? @@ -55904,7 +58312,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 === 226 /* 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 : @@ -55918,7 +58326,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221 /* FunctionDeclaration */: + case 225 /* 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 : @@ -55953,9 +58361,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 */)) { @@ -55971,24 +58379,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 */ ? @@ -55996,7 +58404,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 === 226 /* 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 : @@ -56009,7 +58417,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 225 /* 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 : @@ -56021,12 +58429,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 === 172 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 173 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -56037,7 +58445,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194 /* OmittedExpression */) { + if (bindingElement.kind === 198 /* 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) @@ -56046,7 +58454,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 170 /* BindingElement */) { + else if (bindingElement.kind === 174 /* 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" @@ -56085,40 +58493,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 225 /* FunctionDeclaration */: + case 230 /* ModuleDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 227 /* InterfaceDeclaration */: + case 226 /* ClassDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 229 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 237 /* ExportDeclaration */: + case 241 /* 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 260 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* SourceFile */: + case 261 /* SourceFile */: return emitSourceFile(node); } } @@ -56209,6 +58617,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 @@ -56306,6 +58715,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -56499,7 +58909,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 256 /* SourceFile */: + case 261 /* SourceFile */: return emitSourceFile(node); } } @@ -56555,210 +58965,218 @@ 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 199 /* 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 emitIndexedAccessType(node); + case 170 /* MappedType */: + return emitMappedType(node); + case 171 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 168 /* ObjectBindingPattern */: + case 172 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 169 /* ArrayBindingPattern */: + case 173 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 170 /* BindingElement */: + case 174 /* BindingElement */: return emitBindingElement(node); // Misc - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: return emitTemplateSpan(node); - case 199 /* SemicolonClassElement */: + case 203 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 200 /* Block */: + case 204 /* Block */: return emitBlock(node); - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: return emitVariableStatement(node); - case 202 /* EmptyStatement */: + case 206 /* EmptyStatement */: return emitEmptyStatement(); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: return emitExpressionStatement(node); - case 204 /* IfStatement */: + case 208 /* IfStatement */: return emitIfStatement(node); - case 205 /* DoStatement */: + case 209 /* DoStatement */: return emitDoStatement(node); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: return emitWhileStatement(node); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return emitForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: return emitForInStatement(node); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: return emitForOfStatement(node); - case 210 /* ContinueStatement */: + case 214 /* ContinueStatement */: return emitContinueStatement(node); - case 211 /* BreakStatement */: + case 215 /* BreakStatement */: return emitBreakStatement(node); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: return emitReturnStatement(node); - case 213 /* WithStatement */: + case 217 /* WithStatement */: return emitWithStatement(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return emitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: return emitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: return emitThrowStatement(node); - case 217 /* TryStatement */: + case 221 /* TryStatement */: return emitTryStatement(node); - case 218 /* DebuggerStatement */: + case 222 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 220 /* VariableDeclarationList */: + case 224 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 221 /* FunctionDeclaration */: + case 225 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: + case 226 /* ClassDeclaration */: return emitClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return emitModuleBlock(node); - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: return emitCaseBlock(node); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: return emitImportDeclaration(node); - case 232 /* ImportClause */: + case 236 /* ImportClause */: return emitImportClause(node); - case 233 /* NamespaceImport */: + case 237 /* NamespaceImport */: return emitNamespaceImport(node); - case 234 /* NamedImports */: + case 238 /* NamedImports */: return emitNamedImports(node); - case 235 /* ImportSpecifier */: + case 239 /* ImportSpecifier */: return emitImportSpecifier(node); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: return emitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: return emitExportDeclaration(node); - case 238 /* NamedExports */: + case 242 /* NamedExports */: return emitNamedExports(node); - case 239 /* ExportSpecifier */: + case 243 /* ExportSpecifier */: return emitExportSpecifier(node); - case 240 /* MissingDeclaration */: + case 244 /* MissingDeclaration */: return; // Module references - case 241 /* ExternalModuleReference */: + case 245 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: return emitJsxAttribute(node); - case 247 /* JsxSpreadAttribute */: + case 251 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 248 /* JsxExpression */: + case 252 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 249 /* CaseClause */: + case 253 /* CaseClause */: return emitCaseClause(node); - case 250 /* DefaultClause */: + case 254 /* DefaultClause */: return emitDefaultClause(node); - case 251 /* HeritageClause */: + case 255 /* HeritageClause */: return emitHeritageClause(node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 253 /* PropertyAssignment */: + case 257 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 254 /* ShorthandPropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); + case 259 /* SpreadAssignment */: + return emitSpreadAssignment(node); // Enum - case 255 /* EnumMember */: + case 260 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -56795,65 +59213,65 @@ var ts; writeTokenText(kind); return; // Expressions - case 171 /* ArrayLiteralExpression */: + case 175 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 176 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 173 /* PropertyAccessExpression */: + case 177 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 175 /* CallExpression */: + case 179 /* CallExpression */: return emitCallExpression(node); - case 176 /* NewExpression */: + case 180 /* NewExpression */: return emitNewExpression(node); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 178 /* TypeAssertionExpression */: + case 182 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 179 /* ParenthesizedExpression */: + case 183 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 180 /* FunctionExpression */: + case 184 /* FunctionExpression */: return emitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 185 /* ArrowFunction */: return emitArrowFunction(node); - case 182 /* DeleteExpression */: + case 186 /* DeleteExpression */: return emitDeleteExpression(node); - case 183 /* TypeOfExpression */: + case 187 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 184 /* VoidExpression */: + case 188 /* VoidExpression */: return emitVoidExpression(node); - case 185 /* AwaitExpression */: + case 189 /* AwaitExpression */: return emitAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 191 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return emitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return emitConditionalExpression(node); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: return emitTemplateExpression(node); - case 191 /* YieldExpression */: + case 195 /* YieldExpression */: return emitYieldExpression(node); - case 192 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 193 /* ClassExpression */: + case 196 /* SpreadElement */: + return emitSpreadExpression(node); + case 197 /* ClassExpression */: return emitClassExpression(node); - case 194 /* OmittedExpression */: + case 198 /* OmittedExpression */: return; - case 196 /* AsExpression */: + case 200 /* AsExpression */: return emitAsExpression(node); - case 197 /* NonNullExpression */: + case 201 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 242 /* JsxElement */: + case 246 /* JsxElement */: return emitJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 288 /* PartiallyEmittedExpression */: + case 293 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } @@ -56979,7 +59397,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); } @@ -57067,6 +59485,39 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitIndexedAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } + function emitMappedType(node) { + write("{"); + writeLine(); + increaseIndent(); + if (node.readonlyToken) { + write("readonly "); + } + write("["); + emit(node.typeParameter.name); + write(" in "); + emit(node.typeParameter.constraint); + write("]"); + if (node.questionToken) { + write("?"); + } + write(": "); + emit(node.type); + write(";"); + writeLine(); + decreaseIndent(); + write("}"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -57253,7 +59704,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 === 190 /* 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 */))); } @@ -57297,7 +59748,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -57371,7 +59822,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 204 /* IfStatement */) { + if (node.elseStatement.kind === 208 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -57433,7 +59884,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220 /* VariableDeclarationList */) { + if (node.kind === 224 /* VariableDeclarationList */) { emit(node); } else { @@ -57672,7 +60123,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 === 230 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -57912,6 +60363,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } // // Enum // @@ -57997,10 +60454,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) { @@ -58346,7 +60810,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 183 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -58409,10 +60873,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) { @@ -58420,11 +60884,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; } } } @@ -58473,17 +60937,17 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: + case 229 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 231 /* ImportDeclaration */: - case 237 /* ExportDeclaration */: + case 235 /* ImportDeclaration */: + case 241 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: - case 236 /* ExportAssignment */: + case 225 /* FunctionDeclaration */: + case 226 /* ClassDeclaration */: + case 240 /* ExportAssignment */: return generateNameForExportDefault(); - case 193 /* ClassExpression */: + case 197 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58650,7 +61114,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.1.0"; + ts.version = "2.2.0"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -58876,11 +61340,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; @@ -58901,7 +61365,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. @@ -58918,7 +61382,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; }; @@ -58991,6 +61463,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -58998,13 +61471,14 @@ var ts; ts.performance.measure("Program", "beforeProgram", "afterProgram"); return program; function getCommonSourceDirectory() { - if (typeof commonSourceDirectory === "undefined") { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + if (commonSourceDirectory === undefined) { + var emittedFiles = ts.filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary); + if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } else { - commonSourceDirectory = computeCommonSourceDirectory(files); + commonSourceDirectory = computeCommonSourceDirectory(emittedFiles); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { // Make sure directory path ends with directory separator so this string can directly @@ -59027,6 +61501,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; @@ -59034,21 +61614,7 @@ var ts; // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.moduleResolution !== options.moduleResolution) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx) || - (oldOptions.allowJs !== options.allowJs) || - (oldOptions.rootDir !== options.rootDir) || - (oldOptions.configFilePath !== options.configFilePath) || - (oldOptions.baseUrl !== options.baseUrl) || - (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || - !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || - !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || - !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !ts.equalOwnProperties(oldOptions.paths, options.paths)) { + if (ts.changesAffectModuleResolution(oldOptions, options)) { return false; } ts.Debug.assert(!oldProgram.structureIsReused); @@ -59099,29 +61665,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 @@ -59130,15 +61675,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; @@ -59154,11 +61726,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)); } @@ -59247,6 +61822,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) { @@ -59275,179 +61858,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 223 /* 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 234 /* ImportEqualsDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 240 /* 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 255 /* 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 227 /* InterfaceDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 230 /* ModuleDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 228 /* TypeAliasDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 229 /* EnumDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 182 /* 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 226 /* ClassDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: + case 225 /* 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 205 /* VariableStatement */: + // Check modifiers + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 205 /* 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 179 /* CallExpression */: + case 180 /* NewExpression */: + case 199 /* 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); } }); } @@ -59455,8 +62039,7 @@ var ts; return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -59473,9 +62056,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); } @@ -59494,16 +62074,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(235 /* ImportDeclaration */); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -59515,12 +62100,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 235 /* ImportDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 241 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -59535,7 +62121,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226 /* ModuleDeclaration */: + case 230 /* 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. @@ -59547,6 +62133,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. @@ -59572,13 +62162,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("', '") + "'"]; @@ -59644,7 +62231,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); } @@ -59725,9 +62312,12 @@ var ts; // If we already resolved to this file, it must have been a secondary reference. Check file contents // for sameness and possibly issue an error if (previousResolution) { - var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); - if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + // Don't bother reading the file again if it's the same file. + if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { + var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); + if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + } } // don't overwrite previous resolution result saveResolution = false; @@ -59764,29 +62354,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--; @@ -59797,7 +62397,6 @@ var ts; // no imports - drop cached module resolutions file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -59958,7 +62557,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 @@ -59976,12 +62583,18 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + 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)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); } else { emitFilesSeen.set(emitFilePath, true); @@ -59989,12 +62602,40 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, message) { + function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + 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 = {})); /// /// @@ -60075,6 +62716,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", @@ -60263,6 +62909,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, @@ -60426,7 +63073,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 @@ -60580,7 +63228,13 @@ var ts; i++; break; case "boolean": - options[opt.name] = true; + // boolean flag has optional value true, false, others + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } break; case "string": options[opt.name] = args[i] || ""; @@ -60717,11 +63371,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": @@ -60729,14 +63383,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") { @@ -60745,11 +63399,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); } } } @@ -60879,6 +63533,9 @@ var ts; if (ts.hasProperty(json, "files")) { if (ts.isArray(json["files"])) { fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); @@ -60916,7 +63573,11 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; } var _b; } @@ -60952,9 +63613,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; } @@ -61186,6 +63845,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: @@ -61199,14 +63859,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; @@ -61228,6 +63887,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. @@ -61331,12 +64003,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"; @@ -61360,14 +64033,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"; @@ -61376,8 +64049,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"; @@ -61388,8 +64061,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) { @@ -61496,6 +64168,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"; @@ -61521,52 +64194,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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: + case 260 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 256 /* CatchClause */: return 1 /* Value */; - case 142 /* TypeParameter */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 160 /* TypeLiteral */: + case 143 /* TypeParameter */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 161 /* TypeLiteral */: return 2 /* Type */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -61576,22 +64248,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 238 /* NamedImports */: + case 239 /* ImportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 235 /* ImportDeclaration */: + case 240 /* ExportAssignment */: + case 241 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 256 /* SourceFile */: + case 261 /* 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 === 240 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -61616,15 +64288,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 === 234 /* 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; @@ -61635,27 +64307,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 === 177 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 177 /* 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 === 199 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 255 /* 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 === 226 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 227 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -61663,17 +64335,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 === 199 /* 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, 179 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 180 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -61686,7 +64358,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 219 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -61696,13 +64368,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 === 215 /* BreakStatement */ || node.parent.kind === 214 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 215 /* LabeledStatement */ && + node.parent.kind === 219 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -61710,15 +64382,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 === 177 /* 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 === 230 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -61729,19 +64401,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 257 /* PropertyAssignment */: + case 260 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 230 /* ModuleDeclaration */: return node.parent.name === node; - case 174 /* ElementAccessExpression */: + case 178 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return true; } } @@ -61790,17 +64462,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 261 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: return node; } } @@ -61808,46 +64480,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256 /* SourceFile */: + case 261 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226 /* ModuleDeclaration */: + case 230 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 226 /* ClassDeclaration */: + case 197 /* 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 227 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 228 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 229 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 223 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 170 /* BindingElement */: + case 174 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* 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 260 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 234 /* ImportEqualsDeclaration */: + case 239 /* ImportSpecifier */: + case 236 /* ImportClause */: + case 243 /* ExportSpecifier */: + case 237 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -61862,7 +64534,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 === 171 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -61877,7 +64549,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; } @@ -61922,42 +64594,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 176 /* ObjectLiteralExpression */: + case 172 /* ObjectBindingPattern */: + case 161 /* TypeLiteral */: + case 204 /* Block */: + case 231 /* ModuleBlock */: + case 232 /* CaseBlock */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 176 /* NewExpression */: + case 180 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 175 /* CallExpression */: - case 179 /* ParenthesizedExpression */: - case 165 /* ParenthesizedType */: + case 179 /* CallExpression */: + case 183 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 185 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -61967,67 +64639,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 230 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 204 /* IfStatement */: + case 208 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203 /* ExpressionStatement */: + case 207 /* 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 175 /* ArrayLiteralExpression */: + case 173 /* ArrayBindingPattern */: + case 178 /* 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 253 /* CaseClause */: + case 254 /* 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 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 210 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 205 /* DoStatement */: + case 209 /* 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 187 /* TypeOfExpression */: + case 186 /* DeleteExpression */: + case 188 /* VoidExpression */: + case 195 /* YieldExpression */: + case 196 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177 /* TaggedTemplateExpression */: + case 181 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 190 /* TemplateExpression */: + case 194 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198 /* TemplateSpan */: + case 202 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 237 /* ExportDeclaration */: - case 231 /* ImportDeclaration */: + case 241 /* ExportDeclaration */: + case 235 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 186 /* PrefixUnaryExpression */: + case 190 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 188 /* BinaryExpression */: + case 192 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 189 /* ConditionalExpression */: + case 193 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -62083,7 +64755,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 === 291 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -62255,7 +64927,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 261 /* 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. @@ -62314,17 +64986,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 252 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 252 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 249 /* JsxClosingElement */) { return true; } return false; @@ -62436,17 +65108,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 === 179 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 226 /* ClassDeclaration */ || node.kind === 227 /* 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) { @@ -62505,18 +65177,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 /* ArrayLiteralExpression */ || - node.kind === 172 /* ObjectLiteralExpression */) { + if (node.kind === 175 /* ArrayLiteralExpression */ || + node.kind === 176 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 188 /* BinaryExpression */ && + if (node.parent.kind === 192 /* 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 === 213 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -62524,7 +65196,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 === 257 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -62557,7 +65229,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(); @@ -62579,8 +65251,8 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } + trackSymbol: ts.noop, + reportInaccessibleThisError: ts.noop }; function writeIndent() { if (lineStart) { @@ -62737,7 +65409,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' @@ -62749,7 +65421,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 === 239 /* ImportSpecifier */ || location.parent.kind === 243 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -62821,7 +65493,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 @@ -62864,7 +65536,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". @@ -63023,10 +65695,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, @@ -63198,7 +65870,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)) { @@ -63255,10 +65927,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 230 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 225 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -63309,7 +65981,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 /* ModuleDeclaration */ && + return declaration.kind === 230 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -63388,8 +66060,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 */ }; @@ -63473,16 +66145,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 280 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 278 /* JSDocTemplateTag */: + case 283 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 277 /* JSDocTypeTag */: + case 282 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 276 /* JSDocReturnTag */: + case 281 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -63569,22 +66241,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244 /* JsxOpeningElement */: + case 248 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 245 /* JsxClosingElement */: + case 249 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 243 /* JsxSelfClosingElement */: + case 247 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 246 /* JsxAttribute */: + case 250 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -63612,17 +66284,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 === 223 /* VariableDeclaration */ || + token.parent.kind === 147 /* PropertyDeclaration */ || + token.parent.kind === 144 /* Parameter */ || + token.parent.kind === 250 /* 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 === 192 /* BinaryExpression */ || + token.parent.kind === 190 /* PrefixUnaryExpression */ || + token.parent.kind === 191 /* PostfixUnaryExpression */ || + token.parent.kind === 193 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -63632,7 +66304,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 === 250 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -63648,32 +66320,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 222 /* ClassDeclaration */: + case 226 /* 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 227 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 226 /* ModuleDeclaration */: + case 230 /* 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 */; } @@ -63733,7 +66405,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 === 249 /* 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: @@ -63760,14 +66432,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, @@ -63827,8 +66499,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 === 257 /* PropertyAssignment */ && + node.parent.parent.kind === 176 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -63853,7 +66525,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 === 235 /* 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*/"); @@ -63925,7 +66597,7 @@ var ts; if (!type) { return; } - if (type.flags & 524288 /* Union */) { + if (type.flags & 65536 /* Union */) { ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); } else { @@ -64280,11 +66952,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_14 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_14) { break; } - currentDir = parent_16; + currentDir = parent_14; } else { break; @@ -64436,9 +67108,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277 /* JSDocTypeTag */: - case 275 /* JSDocParameterTag */: - case 276 /* JSDocReturnTag */: + case 282 /* JSDocTypeTag */: + case 280 /* JSDocParameterTag */: + case 281 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -64483,13 +67155,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_15 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_17.kind === 173 /* PropertyAccessExpression */) { + if (parent_15.kind === 177 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140 /* QualifiedName */) { + else if (parent_15.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -64504,7 +67176,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 === 249 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -64553,7 +67225,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 === 177 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -64581,7 +67253,7 @@ var ts; symbols.push(symbol); } } - if (isJavaScriptFile && type.flags & 524288 /* Union */) { + if (isJavaScriptFile && type.flags & 65536 /* Union */) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers @@ -64609,7 +67281,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 247 /* JsxSelfClosingElement */) || (jsxContainer.kind === 248 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -64657,9 +67329,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 === 261 /* SourceFile */ || + scopeNode.kind === 194 /* TemplateExpression */ || + scopeNode.kind === 252 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -64692,11 +67364,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 248 /* 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 === 249 /* JsxClosingElement */ || contextToken.parent.kind === 247 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 246 /* JsxElement */; } } return false; @@ -64706,40 +67378,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 === 179 /* CallExpression */ // func( a, | + || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 180 /* NewExpression */ // new C(a, | + || containingNodeKind === 175 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 192 /* 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 === 179 /* CallExpression */ // func( | + || containingNodeKind === 150 /* Constructor */ // constructor( | + || containingNodeKind === 180 /* NewExpression */ // new C(a| + || containingNodeKind === 183 /* 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 === 175 /* 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 === 230 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 226 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 188 /* BinaryExpression */; // x = a| + return containingNodeKind === 223 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 192 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 194 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 202 /* 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()) { @@ -64782,7 +67454,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 176 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -64792,7 +67464,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 172 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -64803,11 +67475,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); } } @@ -64849,9 +67521,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 === 238 /* NamedImports */ ? + 235 /* ImportDeclaration */ : + 241 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -64876,9 +67548,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_16 = contextToken.parent; + if (parent_16 && (parent_16.kind === 176 /* ObjectLiteralExpression */ || parent_16.kind === 172 /* ObjectBindingPattern */)) { + return parent_16; } break; } @@ -64895,8 +67567,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 238 /* NamedImports */: + case 242 /* NamedExports */: return contextToken.parent; } } @@ -64905,37 +67577,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_17 = 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 250 /* JsxAttribute */: + case 251 /* JsxSpreadAttribute */: + if (parent_17 && (parent_17.kind === 247 /* JsxSelfClosingElement */ || parent_17.kind === 248 /* JsxOpeningElement */)) { + return parent_17; } - else if (parent_19.kind === 246 /* JsxAttribute */) { - return parent_19.parent; + else if (parent_17.kind === 250 /* JsxAttribute */) { + return parent_17.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_17 && ((parent_17.kind === 250 /* JsxAttribute */) || (parent_17.kind === 251 /* JsxSpreadAttribute */))) { + return parent_17.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_17 && + parent_17.kind === 252 /* JsxExpression */ && + parent_17.parent && + (parent_17.parent.kind === 250 /* JsxAttribute */)) { + return parent_17.parent.parent; } - if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { - return parent_19.parent; + if (parent_17 && parent_17.kind === 251 /* JsxSpreadAttribute */) { + return parent_17.parent; } break; } @@ -64944,16 +67616,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 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* 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; @@ -64965,66 +67637,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 === 223 /* VariableDeclaration */ || + containingNodeKind === 224 /* VariableDeclarationList */ || + containingNodeKind === 205 /* VariableStatement */ || + containingNodeKind === 229 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 222 /* ClassDeclaration */ || - containingNodeKind === 193 /* ClassExpression */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 169 /* ArrayBindingPattern */ || - containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 226 /* ClassDeclaration */ || + containingNodeKind === 197 /* ClassExpression */ || + containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 173 /* ArrayBindingPattern */ || + containingNodeKind === 228 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 173 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 170 /* BindingElement */; // var {x :html| + return containingNodeKind === 174 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 173 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 252 /* CatchClause */ || + return containingNodeKind === 256 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 225 /* EnumDeclaration */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* TypeLiteral */; // const x : { | + return containingNodeKind === 229 /* EnumDeclaration */ || + containingNodeKind === 227 /* 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 === 227 /* 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 === 226 /* ClassDeclaration */ || + containingNodeKind === 197 /* ClassExpression */ || + containingNodeKind === 227 /* InterfaceDeclaration */ || + containingNodeKind === 228 /* 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 === 173 /* 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 === 239 /* ImportSpecifier */ || + containingNodeKind === 243 /* ExportSpecifier */ || + containingNodeKind === 237 /* 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. @@ -65072,8 +67744,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"; }); @@ -65094,10 +67766,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 !== 257 /* PropertyAssignment */ && + m.kind !== 258 /* ShorthandPropertyAssignment */ && + m.kind !== 174 /* 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 @@ -65105,7 +67779,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 170 /* BindingElement */ && m.propertyName) { + if (m.kind === 174 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -65135,7 +67809,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246 /* JsxAttribute */) { + if (attr.kind === 250 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -65185,7 +67859,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, @@ -65262,7 +67936,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)) { @@ -65316,75 +67990,75 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 204 /* IfStatement */)) { + if (hasKind(node.parent, 208 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 212 /* ReturnStatement */)) { + if (hasKind(node.parent, 216 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 216 /* ThrowStatement */)) { + if (hasKind(node.parent, 220 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 221 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 217 /* TryStatement */)) { + if (hasKind(parent(node), 221 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 214 /* SwitchStatement */)) { + if (hasKind(node.parent, 218 /* 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))), 218 /* 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, 215 /* BreakStatement */) || hasKind(node.parent, 214 /* 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, 211 /* ForStatement */) || + hasKind(node.parent, 212 /* ForInStatement */) || + hasKind(node.parent, 213 /* 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, 210 /* WhileStatement */) || hasKind(node.parent, 209 /* 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 === 205 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -65400,10 +68074,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216 /* ThrowStatement */) { + if (node.kind === 220 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 217 /* TryStatement */) { + else if (node.kind === 221 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -65430,19 +68104,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_18 = child.parent; + if (ts.isFunctionBlock(parent_18) || parent_18.kind === 261 /* SourceFile */) { + return parent_18; } // 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_18.kind === 221 /* TryStatement */) { + var tryStatement = parent_18; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_18; } return undefined; } @@ -65451,7 +68125,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { + if (node.kind === 215 /* BreakStatement */ || node.kind === 214 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -65466,16 +68140,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 218 /* SwitchStatement */: + if (statement.kind === 214 /* ContinueStatement */) { continue; } // Fall through. - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 210 /* WhileStatement */: + case 209 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -65494,24 +68168,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 === 226 /* ClassDeclaration */ || + container.kind === 197 /* 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 === 226 /* ClassDeclaration */ || container.kind === 197 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + if (!(container.kind === 231 /* ModuleBlock */ || container.kind === 261 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { + if (!(container.kind === 226 /* ClassDeclaration */ || declaration.kind === 226 /* ClassDeclaration */)) { return undefined; } } @@ -65523,8 +68197,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: + case 231 /* ModuleBlock */: + case 261 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -65533,17 +68207,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 226 /* ClassDeclaration */: + case 197 /* 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); @@ -65596,13 +68270,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 */); }); } } } @@ -65620,7 +68294,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 === 209 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -65641,13 +68315,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 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 209 /* DoStatement */: + case 210 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -65701,7 +68375,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, 204 /* Block */))) { return undefined; } var keywords = []; @@ -65717,7 +68391,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, 208 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -65730,7 +68404,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 208 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -65773,7 +68447,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 === 219 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -66007,12 +68681,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, 236 /* 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 === 239 /* ImportSpecifier */ || + declaration.kind === 243 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -66020,7 +68694,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 === 239 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -66035,14 +68709,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 172 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 174 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -66072,14 +68746,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 === 184 /* FunctionExpression */ || valueDeclaration.kind === 197 /* 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, 226 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -66110,7 +68784,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 256 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 261 /* 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; @@ -66141,8 +68815,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); } @@ -66274,7 +68948,7 @@ var ts; if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { return [localParentType.symbol]; } - else if (localParentType.flags & 1572864 /* UnionOrIntersection */) { + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { return getSymbolsForClassAndInterfaceComponents(localParentType); } } @@ -66314,14 +68988,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) { @@ -66344,7 +69018,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) { @@ -66386,7 +69060,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 258 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -66399,24 +69073,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_19 = containingTypeReference.parent; + if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_19.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_19) && parent_19.type === containingTypeReference && parent_19.body) { + if (parent_19.body.kind === 204 /* Block */) { + ts.forEachReturnStatement(parent_19.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_19.body)) { + maybeAdd(getReferenceEntryFromNode(parent_19.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_19.expression)); } } } @@ -66438,7 +69112,7 @@ var ts; if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { result.push(componentType.symbol); } - if (componentType.getFlags() & 1572864 /* UnionOrIntersection */) { + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { getSymbolsForClassAndInterfaceComponents(componentType, result); } } @@ -66456,12 +69130,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 /* ExpressionWithTypeArguments */ - && node.parent.kind === 251 /* HeritageClause */ + if (node.kind === 199 /* ExpressionWithTypeArguments */ + && node.parent.kind === 255 /* 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 === 177 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -66472,14 +69146,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 183 /* 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 === 185 /* ArrowFunction */ || + node.kind === 184 /* FunctionExpression */ || + node.kind === 176 /* ObjectLiteralExpression */ || + node.kind === 197 /* ClassExpression */ || + node.kind === 175 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -66528,7 +69202,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 227 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -66556,13 +69230,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; @@ -66594,27 +69268,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 261 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 184 /* 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. @@ -66623,7 +69297,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256 /* SourceFile */) { + if (searchSpaceNode.kind === 261 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -66657,28 +69331,28 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 225 /* 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 197 /* ClassExpression */: + case 226 /* 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 261 /* SourceFile */: + if (container.kind === 261 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -66718,8 +69392,8 @@ var ts; if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { return; } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { + var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_2 === searchType) { references.push(getReferenceEntryFromNode(node_2)); } } @@ -66732,7 +69406,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 !== 258 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -66780,7 +69454,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)); } @@ -66835,7 +69509,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 227 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -66919,7 +69593,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)) { @@ -66939,7 +69613,7 @@ var ts; if (symbol_2) { result_4.push(symbol_2); } - if (contextualType.flags & 524288 /* Union */) { + if (contextualType.flags & 65536 /* Union */) { ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -67001,7 +69675,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219 /* VariableDeclaration */) { + else if (node.kind === 223 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -67011,18 +69685,18 @@ var ts; } else { switch (node.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 229 /* EnumDeclaration */: + case 230 /* 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 === 205 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 224 /* VariableDeclarationList */); return node.parent.parent; } } @@ -67061,10 +69735,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { + if (parent.kind === 191 /* PostfixUnaryExpression */ || parent.kind === 190 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 192 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -67086,7 +69760,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 @@ -67097,11 +69771,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 257 /* PropertyAssignment */: + case 258 /* ShorthandPropertyAssignment */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return true; } return false; @@ -67176,7 +69850,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { + (declaration.kind === 239 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 238 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -67185,7 +69859,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 === 258 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -67213,7 +69887,7 @@ var ts; if (!type) { return undefined; } - if (type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */)) { + if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { var result_5 = []; ts.forEach(type.types, function (t) { if (t.symbol) { @@ -67268,8 +69942,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 === 225 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -67349,7 +70023,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 === 258 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -67515,19 +70189,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 225 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: + case 226 /* ClassDeclaration */: + case 205 /* VariableStatement */: break findOwner; - case 256 /* SourceFile */: + case 261 /* SourceFile */: return undefined; - case 226 /* ModuleDeclaration */: + case 230 /* 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 === 230 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -67568,7 +70242,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201 /* VariableStatement */) { + if (commentOwner.kind === 205 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -67586,17 +70260,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 === 183 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return rightHandSide.parameters; - case 193 /* ClassExpression */: + case 197 /* 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; } } @@ -67622,6 +70296,16 @@ var ts; // that we are confident require typings var safeList; var EmptySafeList = ts.createMap(); + /* @internal */ + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project @@ -67631,7 +70315,7 @@ var ts; * @param typingOptions are used to customize the typing inference process * @param compilerOptions are used as a source for typing inference */ - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, unresolvedImports) { // A typing name to typing file path mapping var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { @@ -67653,7 +70337,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); @@ -67667,15 +70351,25 @@ var ts; getTypingNamesFromNodeModuleFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); + // add typings for unresolved imports + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } + } + } // 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 - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; + for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { + var excludeTypingName = exclude_1[_b]; delete inferredTypings[excludeTypingName]; } var newTypingNames = []; @@ -67707,10 +70401,12 @@ var ts; * Get the typing info from common package manager json files like package.json or bower.json */ function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); if (result.config) { var jsonConfig = result.config; - filesToWatch.push(jsonPath); if (jsonConfig.dependencies) { mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); } @@ -67806,12 +70502,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; } @@ -67824,14 +70520,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 }); } } } @@ -67839,7 +70535,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 === 236 /* ImportClause */ || decl.kind === 239 /* ImportSpecifier */ || decl.kind === 234 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -67881,7 +70577,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 { @@ -67902,7 +70598,7 @@ var ts; } return true; } - if (expression.kind === 173 /* PropertyAccessExpression */) { + if (expression.kind === 177 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -67915,7 +70611,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; } @@ -68068,7 +70764,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); @@ -68080,21 +70776,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 236 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -68106,7 +70802,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 237 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -68117,12 +70813,12 @@ var ts; } } break; - case 170 /* BindingElement */: - case 219 /* VariableDeclaration */: + case 174 /* BindingElement */: + case 223 /* 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. @@ -68132,12 +70828,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 225 /* EnumDeclaration */: + case 229 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -68147,9 +70843,9 @@ var ts; } endNode(); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -68157,21 +70853,21 @@ var ts; } endNode(); break; - case 226 /* ModuleDeclaration */: + case 230 /* 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 243 /* ExportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 155 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 228 /* 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 === 284 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -68222,14 +70918,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 !== 230 /* 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 !== 230 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -68289,7 +70985,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 230 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -68297,18 +70993,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 193 /* ClassExpression */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 197 /* ClassExpression */: return getFunctionOrClassName(node); - case 279 /* JSDocTypedefTag */: + case 284 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 230 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -68319,29 +71015,32 @@ var ts; } } switch (node.kind) { - case 256 /* SourceFile */: + case 261 /* 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 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } + // We may get a string with newlines or other whitespace in the case of an object dereference + // (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 284 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -68353,7 +71052,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 205 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -68382,24 +71081,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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 229 /* EnumDeclaration */: + case 227 /* InterfaceDeclaration */: + case 230 /* ModuleDeclaration */: + case 261 /* SourceFile */: + case 228 /* TypeAliasDeclaration */: + case 284 /* 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 223 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -68409,10 +71108,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: - case 148 /* MethodDeclaration */: - case 149 /* Constructor */: + case 231 /* ModuleBlock */: + case 261 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -68421,7 +71120,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 !== 223 /* VariableDeclaration */ && childKind !== 174 /* BindingElement */; }); } } @@ -68479,7 +71178,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 === 230 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -68490,13 +71189,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 === 230 /* 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 === 261 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -68504,14 +71203,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 === 223 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 /* BinaryExpression */ && + else if (node.parent.kind === 192 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { - return nodeText(node.parent.left); + return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 257 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -68522,8 +71221,22 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; + return node.kind === 184 /* FunctionExpression */ || node.kind === 185 /* ArrowFunction */ || node.kind === 197 /* ClassExpression */; } + /** + * Matches all whitespace characters in a string. Eg: + * + * "app. + * + * onactivated" + * + * matches because of the newline, whereas + * + * "app.onactivated" + * + * does not match. + */ + var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -68598,7 +71311,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 185 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -68610,30 +71323,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200 /* Block */: + case 204 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_20 = 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_20.kind === 209 /* DoStatement */ || + parent_20.kind === 212 /* ForInStatement */ || + parent_20.kind === 213 /* ForOfStatement */ || + parent_20.kind === 211 /* ForStatement */ || + parent_20.kind === 208 /* IfStatement */ || + parent_20.kind === 210 /* WhileStatement */ || + parent_20.kind === 217 /* WithStatement */ || + parent_20.kind === 256 /* CatchClause */) { + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217 /* TryStatement */) { + if (parent_20.kind === 221 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_22; + var tryStatement = parent_20; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -68656,23 +71369,23 @@ var ts; break; } // Fallthrough. - case 227 /* ModuleBlock */: { + case 231 /* 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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 176 /* ObjectLiteralExpression */: + case 232 /* 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 175 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -68692,13 +71405,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, @@ -69029,7 +71742,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 @@ -69042,7 +71755,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 @@ -69320,7 +72033,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(); @@ -69345,7 +72058,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"; @@ -69376,7 +72089,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"; @@ -69392,7 +72105,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" @@ -69422,7 +72135,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"; @@ -69434,7 +72147,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" @@ -69459,7 +72172,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(); @@ -69814,12 +72527,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 @@ -69850,7 +72563,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 179 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -69858,7 +72571,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 173 /* PropertyAccessExpression */ + : expression.kind === 177 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -69891,7 +72604,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 === 179 /* CallExpression */ || node.parent.kind === 180 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -69945,25 +72658,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 === 181 /* 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 === 181 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 194 /* 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 === 202 /* TemplateSpan */ && node.parent.parent.parent.kind === 181 /* 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 === 194 /* 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; @@ -70081,7 +72794,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 === 194 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -70090,7 +72803,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 !== 261 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -70150,7 +72863,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; @@ -70161,6 +72876,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); }); @@ -70175,7 +72891,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], @@ -70232,7 +72948,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, 197 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -70338,7 +73054,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 === 177 /* 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)) { @@ -70347,7 +73063,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 === 179 /* CallExpression */ || location.kind === 180 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -70360,7 +73076,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 === 180 /* 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 @@ -70400,7 +73116,7 @@ var ts; displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 2097152 /* Anonymous */) && type.symbol) { + if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); @@ -70413,24 +73129,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); @@ -70439,7 +73155,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 197 /* 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 @@ -70462,7 +73178,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); @@ -70483,9 +73199,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 230 /* 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); } @@ -70496,36 +73212,36 @@ var ts; displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91 /* InKeyword */)); - displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter + addInPrefix(); addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } 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)) { + addInPrefix(); 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 */)); } - else { + else if (declaration.kind === 228 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); + addInPrefix(); + displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -70536,7 +73252,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255 /* EnumMember */) { + if (declaration.kind === 260 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -70548,10 +73264,10 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 233 /* 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 */)); @@ -70559,13 +73275,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230 /* ImportEqualsDeclaration */) { + if (declaration.kind === 234 /* 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 */)); @@ -70632,10 +73348,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 === 261 /* 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 !== 192 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -70656,6 +73372,11 @@ var ts; displayParts.push(ts.lineBreakPart()); } } + function addInPrefix() { + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(91 /* InKeyword */)); + displayParts.push(ts.spacePart()); + } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); @@ -70711,16 +73432,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 180 /* FunctionExpression */) { + if (declaration.kind === 184 /* FunctionExpression */) { return true; } - if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { + if (declaration.kind !== 223 /* VariableDeclaration */ && declaration.kind !== 225 /* 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_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { + if (parent_21.kind === 261 /* SourceFile */ || parent_21.kind === 231 /* ModuleBlock */) { return false; } } @@ -70831,7 +73552,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_2 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -70850,7 +73571,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); + _loop_4(opt); } return options; } @@ -70862,8 +73583,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 */ @@ -70958,10 +73679,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 250 /* JsxAttribute */: + case 248 /* JsxOpeningElement */: + case 249 /* JsxClosingElement */: + case 247 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -71196,14 +73917,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 = {})); /// @@ -71235,13 +73956,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 = {})); /// @@ -71282,11 +74003,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 = {})); /// @@ -71437,7 +74158,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 */)); @@ -71445,10 +74166,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 @@ -71468,7 +74189,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 */)); @@ -71596,9 +74317,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"); @@ -71607,42 +74328,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 207 /* ForStatement */; + return context.contextNode.kind === 211 /* 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 192 /* BinaryExpression */: + case 193 /* ConditionalExpression */: + case 200 /* AsExpression */: + case 243 /* ExportSpecifier */: + case 239 /* 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 174 /* BindingElement */: // equals in type X = ... - case 224 /* TypeAliasDeclaration */: + case 228 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 219 /* VariableDeclaration */: + case 223 /* VariableDeclaration */: // equal in p = 0; - case 143 /* Parameter */: - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 144 /* Parameter */: + case 260 /* 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 212 /* 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 213 /* ForOfStatement */: + return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; }; @@ -71650,7 +74371,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189 /* ConditionalExpression */; + return context.contextNode.kind === 193 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -71694,97 +74415,97 @@ var ts; return true; } switch (node.kind) { - case 200 /* Block */: - case 228 /* CaseBlock */: - case 172 /* ObjectLiteralExpression */: - case 227 /* ModuleBlock */: + case 204 /* Block */: + case 232 /* CaseBlock */: + case 176 /* ObjectLiteralExpression */: + case 231 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 225 /* 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 184 /* FunctionExpression */: + case 150 /* Constructor */: + case 185 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 223 /* InterfaceDeclaration */: + case 227 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; + return context.contextNode.kind === 225 /* FunctionDeclaration */ || context.contextNode.kind === 184 /* 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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 161 /* TypeLiteral */: + case 230 /* ModuleDeclaration */: + case 241 /* ExportDeclaration */: + case 242 /* NamedExports */: + case 235 /* ImportDeclaration */: + case 238 /* 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 226 /* ClassDeclaration */: + case 230 /* ModuleDeclaration */: + case 229 /* EnumDeclaration */: + case 204 /* Block */: + case 256 /* CatchClause */: + case 231 /* ModuleBlock */: + case 218 /* 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 208 /* IfStatement */: + case 218 /* SwitchStatement */: + case 211 /* ForStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 210 /* WhileStatement */: + case 221 /* TryStatement */: + case 209 /* DoStatement */: + case 217 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 252 /* CatchClause */: + case 256 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172 /* ObjectLiteralExpression */; + return context.contextNode.kind === 176 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 175 /* CallExpression */; + return context.contextNode.kind === 179 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176 /* NewExpression */; + return context.contextNode.kind === 180 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -71796,25 +74517,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181 /* ArrowFunction */; + return context.contextNode.kind === 185 /* 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 !== 246 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248 /* JsxExpression */; + return context.contextNode.kind === 252 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246 /* JsxAttribute */; + return context.nextTokenParent.kind === 250 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246 /* JsxAttribute */; + return context.contextNode.kind === 250 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243 /* JsxSelfClosingElement */; + return context.contextNode.kind === 247 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -71829,41 +74550,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 === 224 /* 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 === 230 /* 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 182 /* TypeAssertionExpression */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 199 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -71874,13 +74595,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178 /* TypeAssertionExpression */; + return context.contextNode.kind === 182 /* 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 === 188 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 195 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -71904,7 +74625,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); @@ -71918,7 +74639,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; }; @@ -71955,6 +74676,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"; @@ -71962,8 +74684,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: @@ -72099,7 +74820,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; @@ -72143,9 +74864,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 */]); @@ -72153,7 +74874,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 = {})); @@ -72412,17 +75133,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 226 /* ClassDeclaration */: + case 227 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 226 /* ModuleDeclaration */: + case 230 /* 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 === 231 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 261 /* SourceFile */: + case 204 /* Block */: + case 231 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -72627,20 +75348,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 226 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 227 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 225 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 229 /* EnumDeclaration */: return 229 /* 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; } } @@ -72784,11 +75505,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 === 175 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -73133,12 +75854,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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 185 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -73146,8 +75867,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73155,7 +75876,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 156 /* TypeReference */: + case 157 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73271,7 +75992,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 !== 192 /* 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 */) { @@ -73394,7 +76115,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 === 261 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -73427,7 +76148,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 === 208 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -73439,23 +76160,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 176 /* ObjectLiteralExpression */: return node.parent.properties; - case 171 /* ArrayLiteralExpression */: + case 175 /* 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 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 185 /* 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())) { @@ -73466,8 +76187,8 @@ var ts; } break; } - case 176 /* NewExpression */: - case 175 /* CallExpression */: { + case 180 /* NewExpression */: + case 179 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -73497,8 +76218,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 === 179 /* CallExpression */ || + node.parent.kind === 180 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -73516,10 +76237,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 177 /* PropertyAccessExpression */: + case 178 /* ElementAccessExpression */: node = node.expression; break; default: @@ -73583,48 +76304,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 207 /* ExpressionStatement */: + case 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 229 /* EnumDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 175 /* ArrayLiteralExpression */: + case 204 /* Block */: + case 231 /* ModuleBlock */: + case 176 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 163 /* TupleType */: + case 232 /* CaseBlock */: + case 254 /* DefaultClause */: + case 253 /* CaseClause */: + case 183 /* ParenthesizedExpression */: + case 177 /* PropertyAccessExpression */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 205 /* VariableStatement */: + case 223 /* VariableDeclaration */: + case 240 /* ExportAssignment */: + case 216 /* ReturnStatement */: + case 193 /* ConditionalExpression */: + case 173 /* ArrayBindingPattern */: + case 172 /* ObjectBindingPattern */: + case 248 /* JsxOpeningElement */: + case 247 /* JsxSelfClosingElement */: + case 252 /* JsxExpression */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 144 /* Parameter */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 166 /* ParenthesizedType */: + case 181 /* TaggedTemplateExpression */: + case 189 /* AwaitExpression */: + case 242 /* NamedExports */: + case 238 /* NamedImports */: + case 243 /* ExportSpecifier */: + case 239 /* ImportSpecifier */: return true; } return false; @@ -73633,27 +76354,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 209 /* DoStatement */: + case 210 /* WhileStatement */: + case 212 /* ForInStatement */: + case 213 /* ForOfStatement */: + case 211 /* ForStatement */: + case 208 /* IfStatement */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 185 /* ArrowFunction */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return childKind !== 204 /* Block */; + case 241 /* ExportDeclaration */: + return childKind !== 242 /* NamedExports */; + case 235 /* ImportDeclaration */: + return childKind !== 236 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 238 /* NamedImports */); + case 246 /* JsxElement */: + return childKind !== 249 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -73743,7 +76464,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 == 179 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -73767,7 +76488,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 207 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -73812,7 +76533,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; @@ -73824,7 +76545,6 @@ var ts; this.end = end; this.flags = 0 /* None */; this.transformFlags = undefined; - this.excludeTransformFlags = undefined; this.parent = undefined; this.kind = kind; } @@ -73871,11 +76591,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(291 /* 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); } @@ -73890,11 +76610,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 >= 278 /* FirstJSDocTagNode */ && this.kind <= 290 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -73952,7 +76672,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); @@ -73960,7 +76680,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; }()); @@ -74088,7 +76808,7 @@ var ts; return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; TypeObject.prototype.getBaseTypes = function () { - return this.flags & (32768 /* Class */ | 65536 /* Interface */) + return this.flags & 32768 /* Object */ && this.objectFlags & (1 /* Class */ | 2 /* Interface */) ? this.checker.getBaseTypes(this) : undefined; }; @@ -74163,9 +76883,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 === 177 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -74185,10 +76905,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 225 /* FunctionDeclaration */: + case 184 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -74208,32 +76928,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 226 /* ClassDeclaration */: + case 197 /* ClassExpression */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: + case 229 /* EnumDeclaration */: + case 230 /* ModuleDeclaration */: + case 234 /* ImportEqualsDeclaration */: + case 243 /* ExportSpecifier */: + case 239 /* ImportSpecifier */: + case 234 /* ImportEqualsDeclaration */: + case 236 /* ImportClause */: + case 237 /* 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 223 /* VariableDeclaration */: + case 174 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -74242,19 +76962,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 260 /* EnumMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: addDeclaration(node); break; - case 237 /* ExportDeclaration */: + case 241 /* 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 235 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -74266,7 +76986,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 === 237 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -74421,7 +77141,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. @@ -74599,7 +77319,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function () { }, + writeFile: ts.noop, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality @@ -74796,10 +77516,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 177 /* 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); @@ -74942,15 +77662,15 @@ var ts; return; } switch (node.kind) { - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 177 /* 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 @@ -74967,7 +77687,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 === 230 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -75351,7 +78071,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 === 245 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -75371,7 +78091,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 /* ElementAccessExpression */ && + node.parent.kind === 178 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -75455,113 +78175,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201 /* VariableStatement */: + case 205 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 219 /* VariableDeclaration */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 223 /* 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 225 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 184 /* FunctionExpression */: + case 185 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 200 /* Block */: + case 204 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 227 /* ModuleBlock */: + case 231 /* ModuleBlock */: return spanInBlock(node); - case 252 /* CatchClause */: + case 256 /* CatchClause */: return spanInBlock(node.block); - case 203 /* ExpressionStatement */: + case 207 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 212 /* ReturnStatement */: + case 216 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 206 /* WhileStatement */: + case 210 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 205 /* DoStatement */: + case 209 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 218 /* DebuggerStatement */: + case 222 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 204 /* IfStatement */: + case 208 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 215 /* LabeledStatement */: + case 219 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 215 /* BreakStatement */: + case 214 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 207 /* ForStatement */: + case 211 /* ForStatement */: return spanInForStatement(node); - case 208 /* ForInStatement */: + case 212 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* ForOfStatement */: + case 213 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 214 /* SwitchStatement */: + case 218 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 253 /* CaseClause */: + case 254 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 217 /* TryStatement */: + case 221 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 216 /* ThrowStatement */: + case 220 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 236 /* ExportAssignment */: + case 240 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 230 /* ImportEqualsDeclaration */: + case 234 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 231 /* ImportDeclaration */: + case 235 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 237 /* ExportDeclaration */: + case 241 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ModuleDeclaration */: + case 230 /* 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 226 /* ClassDeclaration */: + case 229 /* EnumDeclaration */: + case 260 /* EnumMember */: + case 174 /* BindingElement */: // span on complete node return textSpan(node); - case 213 /* WithStatement */: + case 217 /* 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 172 /* ObjectBindingPattern */: + case 173 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 227 /* InterfaceDeclaration */: + case 228 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -75591,7 +78311,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 @@ -75604,13 +78324,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 == 196 /* SpreadElement */ || + node.kind === 257 /* PropertyAssignment */ || + node.kind === 258 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188 /* BinaryExpression */) { + if (node.kind === 192 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -75633,22 +78353,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205 /* DoStatement */: + case 209 /* 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 211 /* ForStatement */: + case 213 /* ForOfStatement */: return textSpan(node); - case 188 /* BinaryExpression */: + case 192 /* 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 185 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -75657,13 +78377,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 === 257 /* 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 === 182 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -75671,8 +78391,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 === 223 /* VariableDeclaration */ || + node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -75680,7 +78400,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188 /* BinaryExpression */) { + if (node.parent.kind === 192 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -75706,7 +78426,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 === 212 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -75717,7 +78437,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 === 213 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -75757,7 +78477,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); + (functionDeclaration.parent.kind === 226 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -75780,25 +78500,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226 /* ModuleDeclaration */: + case 230 /* 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 210 /* WhileStatement */: + case 208 /* IfStatement */: + case 212 /* 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 211 /* ForStatement */: + case 213 /* 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 === 224 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -75823,23 +78543,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 !== 198 /* 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 === 174 /* 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 !== 173 /* ArrayBindingPattern */ && node.kind !== 172 /* ObjectBindingPattern */); + var elements = node.kind === 175 /* 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 !== 198 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -75847,18 +78567,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 === 192 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225 /* EnumDeclaration */: + case 229 /* 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 226 /* 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 232 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -75866,24 +78586,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227 /* ModuleBlock */: + case 231 /* 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 229 /* EnumDeclaration */: + case 226 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 200 /* Block */: + case 204 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 252 /* CatchClause */: + case 256 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228 /* CaseBlock */: + case 232 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -75891,7 +78611,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168 /* ObjectBindingPattern */: + case 172 /* 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); @@ -75907,7 +78627,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169 /* ArrayBindingPattern */: + case 173 /* 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); @@ -75922,12 +78642,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 === 209 /* DoStatement */ || + node.parent.kind === 179 /* CallExpression */ || + node.parent.kind === 180 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 179 /* ParenthesizedExpression */) { + if (node.parent.kind === 183 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -75936,21 +78656,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 184 /* FunctionExpression */: + case 225 /* FunctionDeclaration */: + case 185 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 210 /* WhileStatement */: + case 209 /* DoStatement */: + case 211 /* ForStatement */: + case 213 /* ForOfStatement */: + case 179 /* CallExpression */: + case 180 /* NewExpression */: + case 183 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -75960,20 +78680,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 === 257 /* 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 === 182 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205 /* DoStatement */) { + if (node.parent.kind === 209 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -75981,7 +78701,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.kind === 213 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -76063,7 +78783,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; }); }; } @@ -76619,8 +79339,15 @@ var ts; return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + if (resolvedFileName && !compilerOptions.allowJs && ts.fileExtensionIs(resolvedFileName, ".js")) { + return { + resolvedFileName: undefined, + failedLookupLocations: [] + }; + } return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + resolvedFileName: resolvedFileName, failedLookupLocations: result.failedLookupLocations }; }); @@ -76706,7 +79433,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.unresolvedImports); }); }; return CoreServicesShimObject; @@ -76789,11 +79516,7 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -/* tslint:disable:no-unused-variable */ // 'toolsVersion' gets consumed by the managed side, so it's not unused. // TODO: it should be moved into a namespace though. /* @internal */ -var toolsVersion = "2.1"; -/* tslint:enable:no-unused-variable */ - -//# sourceMappingURL=typescriptServices.js.map +var toolsVersion = "2.2"; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 147b38fde19..12fae035226 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -20,462 +20,19 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - 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["QualifiedName"] = 140] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; - 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["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["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; - 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["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; - 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["ExternalModuleReference"] = 241] = "ExternalModuleReference"; - 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["CaseClause"] = 249] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; - 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["SyntaxList"] = 286] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; - SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - 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; - (function (NodeFlags) { - NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Let"] = 1] = "Let"; - NodeFlags[NodeFlags["Const"] = 2] = "Const"; - NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; - NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; - NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; - 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["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; - NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; - NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; - (function (ModifierFlags) { - ModifierFlags[ModifierFlags["None"] = 0] = "None"; - ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; - ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; - ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; - ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; - ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; - ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; - ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; - ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; - ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; - ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; - ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; - ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; - ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; - })(ts.ModifierFlags || (ts.ModifierFlags = {})); - var ModifierFlags = ts.ModifierFlags; - (function (JsxFlags) { - JsxFlags[JsxFlags["None"] = 0] = "None"; - JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; - JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; - JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; - (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; - (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; - (function (FlowFlags) { - FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; - FlowFlags[FlowFlags["Start"] = 2] = "Start"; - FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; - FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; - FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; - FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; - FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; - FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["Label"] = 12] = "Label"; - FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; - })(ts.FlowFlags || (ts.FlowFlags = {})); - var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } 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; - (function (TypeFormatFlags) { - TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; - TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; - TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; - TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; - TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; - TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; - TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; - TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; - TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; - TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; - TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - (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; - (function (TypePredicateKind) { - TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; - TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; - })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); - var TypePredicateKind = ts.TypePredicateKind; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -488,179 +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; - (function (SymbolFlags) { - SymbolFlags[SymbolFlags["None"] = 0] = "None"; - SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; - SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; - SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; - SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; - SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; - SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; - SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; - SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; - SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; - SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; - SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; - SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; - SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; - SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; - SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; - SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; - SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; - SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; - SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; - SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; - SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; - SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; - SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; - SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; - SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; - SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; - SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; - SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; - SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; - SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; - SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; - SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; - SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; - SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; - SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; - SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; - SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; - SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; - SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; - SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; - NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; - NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; - NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; - NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; - NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; - NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; - NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; - (function (TypeFlags) { - TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["Void"] = 1024] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 4096] = "Null"; - TypeFlags[TypeFlags["Never"] = 8192] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 32768] = "Class"; - TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 524288] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; - TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; - TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; - TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; - TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; - TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; - TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; - TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; - TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; - TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; - TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; - (function (SignatureKind) { - SignatureKind[SignatureKind["Call"] = 0] = "Call"; - SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; - (function (IndexKind) { - IndexKind[IndexKind["String"] = 0] = "String"; - IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; - (function (SpecialPropertyAssignmentKind) { - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; - SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; - })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); - var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; + })(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"; @@ -668,266 +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; - (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; - (function (NewLineKind) { - NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; - NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; - })(ts.NewLineKind || (ts.NewLineKind = {})); - var NewLineKind = ts.NewLineKind; - (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; - (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; - (function (LanguageVariant) { - LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; - LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; - })(ts.LanguageVariant || (ts.LanguageVariant = {})); - var LanguageVariant = ts.LanguageVariant; - (function (DiagnosticStyle) { - DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; - DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; - })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); - var DiagnosticStyle = ts.DiagnosticStyle; - (function (WatchDirectoryFlags) { - WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; - WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; - })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); - var WatchDirectoryFlags = ts.WatchDirectoryFlags; - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; - CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; - CharacterCodes[CharacterCodes["space"] = 32] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; - CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; - CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; - CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; - CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; - CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; - CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; - CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["j"] = 106] = "j"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["B"] = 66] = "B"; - CharacterCodes[CharacterCodes["C"] = 67] = "C"; - CharacterCodes[CharacterCodes["D"] = 68] = "D"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["G"] = 71] = "G"; - CharacterCodes[CharacterCodes["H"] = 72] = "H"; - CharacterCodes[CharacterCodes["I"] = 73] = "I"; - CharacterCodes[CharacterCodes["J"] = 74] = "J"; - CharacterCodes[CharacterCodes["K"] = 75] = "K"; - CharacterCodes[CharacterCodes["L"] = 76] = "L"; - CharacterCodes[CharacterCodes["M"] = 77] = "M"; - CharacterCodes[CharacterCodes["N"] = 78] = "N"; - CharacterCodes[CharacterCodes["O"] = 79] = "O"; - CharacterCodes[CharacterCodes["P"] = 80] = "P"; - CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; - CharacterCodes[CharacterCodes["R"] = 82] = "R"; - CharacterCodes[CharacterCodes["S"] = 83] = "S"; - CharacterCodes[CharacterCodes["T"] = 84] = "T"; - CharacterCodes[CharacterCodes["U"] = 85] = "U"; - CharacterCodes[CharacterCodes["V"] = 86] = "V"; - CharacterCodes[CharacterCodes["W"] = 87] = "W"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; - (function (TransformFlags) { - TransformFlags[TransformFlags["None"] = 0] = "None"; - TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; - 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["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["HasComputedFlags"] = 536870912] = "HasComputedFlags"; - 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["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["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["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; - })(ts.TransformFlags || (ts.TransformFlags = {})); - var TransformFlags = ts.TransformFlags; - (function (EmitFlags) { - EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; - EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; - EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; - EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; - EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; - EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; - EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; - EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; - EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; - EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; - EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; - EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; - EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; - EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; - EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; - EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; - EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; - EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; - EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; - EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; - EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; - EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.EmitFlags || (ts.EmitFlags = {})); - var EmitFlags = ts.EmitFlags; - (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; + })(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) { @@ -990,12 +137,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - (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; var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { @@ -1060,12 +201,6 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; - (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; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -1078,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++) { @@ -1337,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); } @@ -1373,6 +520,41 @@ var ts; return result; } ts.deduplicate = deduplicate; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function changesAffectModuleResolution(oldOptions, newOptions) { + return !oldOptions || + (oldOptions.module !== newOptions.module) || + (oldOptions.moduleResolution !== newOptions.moduleResolution) || + (oldOptions.noResolve !== newOptions.noResolve) || + (oldOptions.target !== newOptions.target) || + (oldOptions.noLib !== newOptions.noLib) || + (oldOptions.jsx !== newOptions.jsx) || + (oldOptions.allowJs !== newOptions.allowJs) || + (oldOptions.rootDir !== newOptions.rootDir) || + (oldOptions.configFilePath !== newOptions.configFilePath) || + (oldOptions.baseUrl !== newOptions.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) || + !arrayIsEqualTo(oldOptions.lib, newOptions.lib) || + !arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) || + !equalOwnProperties(oldOptions.paths, newOptions.paths); + } + ts.changesAffectModuleResolution = changesAffectModuleResolution; function compact(array) { var result; if (array) { @@ -1391,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++) { @@ -1400,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) { @@ -1427,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] @@ -1439,17 +655,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; + function replaceElement(array, index, value) { + var result = array.slice(0); + result[index] = value; + return result; } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value, comparer) { + ts.replaceElement = replaceElement; + 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 @@ -1683,6 +899,12 @@ var ts; return Array.isArray ? Array.isArray(value) : value instanceof Array; } ts.isArray = isArray; + function noop() { } + ts.noop = noop; + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; function memoize(callback) { var value; return function () { @@ -1798,6 +1020,17 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText + }; + } + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; function chainDiagnosticMessages(details, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -2190,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); } @@ -2217,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); } @@ -2345,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; } @@ -2413,14 +1670,6 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; - (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; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -2471,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); } @@ -2509,13 +1754,6 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; - (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; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -2627,6 +1865,36 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + var ext = tryGetExtensionFromPath(path); + if (ext !== undefined) { + return ext; + } + Debug.fail("File " + path + " has unknown extension."); + } + ts.extensionFromPath = extensionFromPath; + function tryGetExtensionFromPath(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; + } + } + ts.tryGetExtensionFromPath = tryGetExtensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2900,11 +2168,6 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } - var FileSystemEntryKind; - (function (FileSystemEntryKind) { - FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; - FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; - })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2926,6 +2189,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, @@ -2935,7 +2199,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 { @@ -2943,7 +2207,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); } }; @@ -2958,7 +2222,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 }; @@ -3035,7 +2299,9 @@ var ts; } catch (e) { } - } + }, + setTimeout: setTimeout, + clearTimeout: clearTimeout }; return nodeSystem; } @@ -3153,7 +2419,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." }, @@ -3263,7 +2529,6 @@ var ts; Module_0_has_no_default_export: { code: 1192, category: ts.DiagnosticCategory.Error, key: "Module_0_has_no_default_export_1192", message: "Module '{0}' has no default export." }, An_export_declaration_cannot_have_modifiers: { code: 1193, category: ts.DiagnosticCategory.Error, key: "An_export_declaration_cannot_have_modifiers_1193", message: "An export declaration cannot have modifiers." }, Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: ts.DiagnosticCategory.Error, key: "Export_declarations_are_not_permitted_in_a_namespace_1194", message: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_name_must_be_an_identifier_1195", message: "Catch clause variable name must be an identifier." }, Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_a_type_annotation_1196", message: "Catch clause variable cannot have a type annotation." }, Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: ts.DiagnosticCategory.Error, key: "Catch_clause_variable_cannot_have_an_initializer_1197", message: "Catch clause variable cannot have an initializer." }, An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: ts.DiagnosticCategory.Error, key: "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", message: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, @@ -3381,14 +2646,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}'" }, @@ -3428,7 +2693,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" }, @@ -3466,8 +2731,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." }, @@ -3479,7 +2742,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." }, @@ -3501,9 +2764,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." }, @@ -3550,6 +2811,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." }, @@ -3573,6 +2841,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." }, @@ -3604,6 +2873,10 @@ 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." }, + An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, 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}'." }, @@ -3703,6 +2976,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." }, @@ -3786,7 +3060,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." }, @@ -3823,11 +3097,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." }, @@ -3836,7 +3115,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." }, @@ -3883,6 +3163,8 @@ var ts; Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, + No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, @@ -3890,6 +3172,8 @@ var ts; Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, 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; @@ -3922,7 +3206,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -3932,34 +3216,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, @@ -3967,7 +3252,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -5350,10 +4635,13 @@ var ts; case 44: pos++; return token = 25; + case 46: + 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; @@ -5512,6 +4800,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", @@ -5699,6 +4992,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, @@ -5855,7 +5149,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 @@ -6000,7 +5295,11 @@ var ts; i++; break; case "boolean": - options[opt.name] = true; + var optValue = args[i]; + options[opt.name] = optValue !== "false"; + if (optValue === "false" || optValue === "true") { + i++; + } break; case "string": options[opt.name] = args[i] || ""; @@ -6259,6 +5558,9 @@ var ts; if (ts.hasProperty(json, "files")) { if (ts.isArray(json["files"])) { fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); @@ -6295,7 +5597,11 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + if (result.fileNames.length === 0 && !ts.hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); + } + return result; } var _b; } @@ -6331,9 +5637,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; } @@ -6464,14 +5768,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; @@ -6492,6 +5795,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); @@ -6532,7 +5848,16 @@ var ts; ; var safeList; var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + JsTyping.nodeCoreModuleList = [ + "buffer", "querystring", "events", "http", "cluster", + "zlib", "os", "https", "punycode", "repl", "readline", + "vm", "child_process", "url", "dns", "net", + "dgram", "fs", "path", "string_decoder", "tls", + "crypto", "stream", "util", "assert", "tty", "domain", + "constants", "process", "v8", "timers", "console" + ]; + var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, unresolvedImports) { var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -6551,7 +5876,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); @@ -6565,13 +5890,22 @@ var ts; getTypingNamesFromNodeModuleFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; + if (unresolvedImports) { + for (var _a = 0, unresolvedImports_1 = unresolvedImports; _a < unresolvedImports_1.length; _a++) { + var moduleId = unresolvedImports_1[_a]; + var typingName = moduleId in nodeCoreModules ? "node" : moduleId; + if (!(typingName in inferredTypings)) { + inferredTypings[typingName] = undefined; + } } } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; + 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++) { + var excludeTypingName = exclude_1[_b]; delete inferredTypings[excludeTypingName]; } var newTypingNames = []; @@ -6597,10 +5931,12 @@ var ts; } } function getTypingNamesFromJson(jsonPath, filesToWatch) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); if (result.config) { var jsonConfig = result.config; - filesToWatch.push(jsonPath); if (jsonConfig.dependencies) { mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); } @@ -6666,6 +6002,32 @@ var ts; })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var server; + (function (server) { + server.ActionSet = "action::set"; + server.ActionInvalidate = "action::invalidate"; + server.EventInstall = "event::install"; + var Arguments; + (function (Arguments) { + Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; + Arguments.LogFile = "--logFile"; + Arguments.EnableTelemetry = "--enableTelemetry"; + })(Arguments = server.Arguments || (server.Arguments = {})); + function hasArgument(argumentName) { + return ts.sys.args.indexOf(argumentName) >= 0; + } + server.hasArgument = hasArgument; + function findArgument(argumentName) { + var index = ts.sys.args.indexOf(argumentName); + return index >= 0 && index < ts.sys.args.length - 1 + ? ts.sys.args[index + 1] + : undefined; + } + server.findArgument = findArgument; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; (function (ts) { function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); @@ -6675,24 +6037,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) { @@ -6701,18 +6089,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 { @@ -6723,7 +6099,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -6735,7 +6110,9 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + if (currentDirectory !== undefined) { + return getDefaultTypeRoots(currentDirectory, host); + } } ts.getEffectiveTypeRoots = getEffectiveTypeRoots; function getDefaultTypeRoots(currentDirectory, host) { @@ -6743,17 +6120,12 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + forEachAncestorDirectory(currentDirectory, function (directory) { + var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_1 = ts.getDirectoryPath(currentDirectory); - if (parent_1 === currentDirectory) { - break; - } - currentDirectory = parent_1; - } + }); return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); @@ -6762,7 +6134,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -6785,62 +6156,57 @@ var ts; } } var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { + var resolved = primaryLookup(); + var primary = true; + if (!resolved) { + resolved = secondaryLookup(); + primary = false; + } + var resolvedTypeReferenceDirective; + if (resolved) { + resolved = realpath(resolved, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_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) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + } + return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + function primaryLookup() { + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + return ts.forEach(typeRoots, function (typeRoot) { + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + }); + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = 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); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + function secondaryLookup() { + var resolvedFile; + 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); } - else { + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState)); + if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } + return resolvedFile; + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } } } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; function getAutomaticTypeDirectiveNames(options, host) { @@ -6907,15 +6273,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; } @@ -6949,7 +6315,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; } @@ -6966,7 +6332,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; } @@ -6977,7 +6343,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; } @@ -6992,77 +6358,87 @@ var ts; matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedStar_1 = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; + return ts.forEach(state.compilerOptions.paths[matchedPatternText], function (subst) { + var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst; var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); 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 tsExtension = ts.tryGetExtensionFromPath(candidate); + if (tsExtension !== undefined) { + var path_1 = tryFile(candidate, failedLookupLocations, false, state); + return path_1 && { path: path_1, extension: tsExtension }; } - } - return undefined; + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + }); } else { var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); 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, 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); + return resolved_1 && { resolved: { path: realpath(resolved_1.path, host, traceEnabled), extension: resolved_1.extension }, 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 realpath(path, host, traceEnabled) { + if (!host.realpath) { + return path; + } + var real = ts.normalizePath(host.realpath(path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); + } + return real; + } + 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; } @@ -7072,21 +6448,30 @@ 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) { + function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); @@ -7097,29 +6482,32 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); } - failedLookupLocation.push(fileName); + failedLookupLocations.push(fileName); return undefined; } } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { var packageJsonPath = pathToPackageJson(candidate); var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); if (directoryExists && state.host.fileExists(packageJsonPath)) { 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, failedLookupLocations, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocations, 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); } } } @@ -7127,95 +6515,96 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } - failedLookupLocation.push(packageJsonPath); + failedLookupLocations.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !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) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + return loadModuleFromNodeModulesWorker(2, moduleName, directory, failedLookupLocations, state, true); } - function loadModuleFromNodeModulesWorker(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; - } + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + return forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { + if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { + return loadModuleFromNodeModulesOneLevel(extensions, moduleName, ancestorDirectory, failedLookupLocations, state, typesOnly); } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; - } - directory = parentPath; + }); + } + function loadModuleFromNodeModulesOneLevel(extensions, moduleName, directory, failedLookupLocations, state, typesOnly) { + if (typesOnly === void 0) { typesOnly = false; } + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + if (packageResult) { + return packageResult; + } + if (extensions !== 1) { + return loadModuleFromNodeModulesFolder(2, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); } - return undefined; } 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 = forEachAncestorDirectory(containingDirectory, function (directory) { + var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); + return loadModuleFromFile(extensions, searchName, failedLookupLocations, false, 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 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 = loadModuleFromNodeModulesOneLevel(2, moduleName, globalCache, failedLookupLocations, state); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; + function forEachAncestorDirectory(directory, callback) { while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - return referencedSourceFile; + var result = callback(directory); + if (result !== undefined) { + return result; } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { return undefined; } - containingDirectory = parentPath; + directory = parentPath; } } })(ts || (ts = {})); @@ -7227,24 +6616,27 @@ var ts; (function (typingsInstaller) { var nullLog = { isEnabled: function () { return false; }, - writeLine: function () { } + writeLine: ts.noop }; function typingToFileName(cachePath, packageName, installTypingHost) { 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"; - PackageNameValidationResult[PackageNameValidationResult["NameTooLong"] = 2] = "NameTooLong"; - PackageNameValidationResult[PackageNameValidationResult["NameStartsWithDot"] = 3] = "NameStartsWithDot"; - PackageNameValidationResult[PackageNameValidationResult["NameStartsWithUnderscore"] = 4] = "NameStartsWithUnderscore"; - PackageNameValidationResult[PackageNameValidationResult["NameContainsNonURISafeCharacters"] = 5] = "NameContainsNonURISafeCharacters"; - })(typingsInstaller.PackageNameValidationResult || (typingsInstaller.PackageNameValidationResult = {})); - var PackageNameValidationResult = typingsInstaller.PackageNameValidationResult; + PackageNameValidationResult[PackageNameValidationResult["EmptyName"] = 2] = "EmptyName"; + PackageNameValidationResult[PackageNameValidationResult["NameTooLong"] = 3] = "NameTooLong"; + PackageNameValidationResult[PackageNameValidationResult["NameStartsWithDot"] = 4] = "NameStartsWithDot"; + PackageNameValidationResult[PackageNameValidationResult["NameStartsWithUnderscore"] = 5] = "NameStartsWithUnderscore"; + PackageNameValidationResult[PackageNameValidationResult["NameContainsNonURISafeCharacters"] = 6] = "NameContainsNonURISafeCharacters"; + })(PackageNameValidationResult = typingsInstaller.PackageNameValidationResult || (typingsInstaller.PackageNameValidationResult = {})); typingsInstaller.MaxPackageNameLength = 214; function validatePackageName(packageName) { - ts.Debug.assert(!!packageName, "Package name is not specified"); + if (!packageName) { + return PackageNameValidationResult.EmptyName; + } if (packageName.length > typingsInstaller.MaxPackageNameLength) { return PackageNameValidationResult.NameTooLong; } @@ -7263,14 +6655,14 @@ var ts; return PackageNameValidationResult.Ok; } typingsInstaller.validatePackageName = validatePackageName; - typingsInstaller.NpmViewRequest = "npm view"; - typingsInstaller.NpmInstallRequest = "npm install"; var TypingsInstaller = (function () { - function TypingsInstaller(globalCachePath, safeListPath, throttleLimit, log) { + function TypingsInstaller(installTypingHost, globalCachePath, safeListPath, throttleLimit, telemetryEnabled, log) { if (log === void 0) { log = nullLog; } + this.installTypingHost = installTypingHost; this.globalCachePath = globalCachePath; this.safeListPath = safeListPath; this.throttleLimit = throttleLimit; + this.telemetryEnabled = telemetryEnabled; this.log = log; this.packageNameToTypingLocation = ts.createMap(); this.missingTypingsSet = ts.createMap(); @@ -7282,10 +6674,8 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Global cache location '" + globalCachePath + "', safe file path '" + safeListPath + "'"); } - } - TypingsInstaller.prototype.init = function () { this.processCacheLocation(this.globalCachePath); - }; + } TypingsInstaller.prototype.closeProject = function (req) { this.closeWatchers(req.projectName); }; @@ -7319,7 +6709,7 @@ var ts; } this.processCacheLocation(req.cachePath); } - var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, req.fileNames, req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, req.typingOptions); + var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, req.fileNames, req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, req.typingOptions, req.unresolvedImports); if (this.log.isEnabled()) { this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult)); } @@ -7396,12 +6786,22 @@ var ts; } var validationResult = validatePackageName(typing); if (validationResult === PackageNameValidationResult.Ok) { - result.push(typing); + if (typing in this.typesRegistry) { + result.push(typing); + } + else { + if (this.log.isEnabled()) { + this.log.writeLine("Entry for package '" + typing + "' does not exist in local types registry - skipping..."); + } + } } else { this.missingTypingsSet[typing] = true; if (this.log.isEnabled()) { switch (validationResult) { + case PackageNameValidationResult.EmptyName: + this.log.writeLine("Package name '" + typing + "' cannot be empty"); + break; case PackageNameValidationResult.NameTooLong: this.log.writeLine("Package name '" + typing + "' should be less than " + typingsInstaller.MaxPackageNameLength + " characters"); break; @@ -7423,19 +6823,8 @@ var ts; } return result; }; - TypingsInstaller.prototype.installTypings = function (req, cachePath, currentlyCachedTypings, typingsToInstall) { - var _this = this; - if (this.log.isEnabled()) { - this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); - } - typingsToInstall = this.filterTypings(typingsToInstall); - if (typingsToInstall.length === 0) { - if (this.log.isEnabled()) { - this.log.writeLine("All typings are known to be missing or invalid - no need to go any further"); - } - return; - } - var npmConfigPath = ts.combinePaths(cachePath, "package.json"); + TypingsInstaller.prototype.ensurePackageDirectoryExists = function (directory) { + var npmConfigPath = ts.combinePaths(directory, "package.json"); if (this.log.isEnabled()) { this.log.writeLine("Npm config file: " + npmConfigPath); } @@ -7443,22 +6832,54 @@ var ts; if (this.log.isEnabled()) { this.log.writeLine("Npm config file: '" + npmConfigPath + "' is missing, creating new one..."); } - this.ensureDirectoryExists(cachePath, this.installTypingHost); + this.ensureDirectoryExists(directory, this.installTypingHost); this.installTypingHost.writeFile(npmConfigPath, "{}"); } - this.runInstall(cachePath, typingsToInstall, function (installedTypings) { - if (_this.log.isEnabled()) { - _this.log.writeLine("Requested to install typings " + JSON.stringify(typingsToInstall) + ", installed typings " + JSON.stringify(installedTypings)); + }; + TypingsInstaller.prototype.installTypings = function (req, cachePath, currentlyCachedTypings, typingsToInstall) { + var _this = this; + if (this.log.isEnabled()) { + this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); + } + var filteredTypings = this.filterTypings(typingsToInstall); + var scopedTypings = filteredTypings.map(function (x) { return "@types/" + x; }); + if (scopedTypings.length === 0) { + if (this.log.isEnabled()) { + this.log.writeLine("All typings are known to be missing or invalid - no need to go any further"); + } + return; + } + this.ensurePackageDirectoryExists(cachePath); + var requestId = this.installRunCount; + this.installRunCount++; + this.installTypingsAsync(requestId, scopedTypings, cachePath, function (ok) { + if (_this.telemetryEnabled) { + _this.sendResponse({ + kind: server.EventInstall, + packagesToInstall: scopedTypings, + installSuccess: ok + }); + } + if (!ok) { + if (_this.log.isEnabled()) { + _this.log.writeLine("install request failed, marking packages as missing to prevent repeated requests: " + JSON.stringify(filteredTypings)); + } + for (var _i = 0, filteredTypings_1 = filteredTypings; _i < filteredTypings_1.length; _i++) { + var typing = filteredTypings_1[_i]; + _this.missingTypingsSet[typing] = true; + } + return; + } + if (_this.log.isEnabled()) { + _this.log.writeLine("Requested to install typings " + JSON.stringify(scopedTypings) + ", installed typings " + JSON.stringify(scopedTypings)); } - var installedPackages = ts.createMap(); var installedTypingFiles = []; - for (var _i = 0, installedTypings_1 = installedTypings; _i < installedTypings_1.length; _i++) { - var t = installedTypings_1[_i]; + for (var _a = 0, scopedTypings_1 = scopedTypings; _a < scopedTypings_1.length; _a++) { + var t = scopedTypings_1[_a]; var packageName = ts.getBaseFileName(t); if (!packageName) { continue; } - installedPackages[packageName] = true; var typingFile = typingToFileName(cachePath, packageName, _this.installTypingHost); if (!typingFile) { continue; @@ -7471,49 +6892,9 @@ var ts; if (_this.log.isEnabled()) { _this.log.writeLine("Installed typing files " + JSON.stringify(installedTypingFiles)); } - for (var _a = 0, typingsToInstall_2 = typingsToInstall; _a < typingsToInstall_2.length; _a++) { - var toInstall = typingsToInstall_2[_a]; - if (!installedPackages[toInstall]) { - if (_this.log.isEnabled()) { - _this.log.writeLine("New missing typing package '" + toInstall + "'"); - } - _this.missingTypingsSet[toInstall] = true; - } - } _this.sendResponse(_this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles))); }); }; - TypingsInstaller.prototype.runInstall = function (cachePath, typingsToInstall, postInstallAction) { - var requestId = this.installRunCount; - this.installRunCount++; - var execInstallCmdCount = 0; - var filteredTypings = []; - for (var _i = 0, typingsToInstall_3 = typingsToInstall; _i < typingsToInstall_3.length; _i++) { - var typing = typingsToInstall_3[_i]; - filterExistingTypings(this, typing); - } - function filterExistingTypings(self, typing) { - self.execAsync(typingsInstaller.NpmViewRequest, requestId, [typing], cachePath, function (ok) { - if (ok) { - filteredTypings.push(typing); - } - execInstallCmdCount++; - if (execInstallCmdCount === typingsToInstall.length) { - installFilteredTypings(self, filteredTypings); - } - }); - } - function installFilteredTypings(self, filteredTypings) { - if (filteredTypings.length === 0) { - postInstallAction([]); - return; - } - var scopedTypings = filteredTypings.map(function (t) { return "@types/" + t; }); - self.execAsync(typingsInstaller.NpmInstallRequest, requestId, scopedTypings, cachePath, function (ok) { - postInstallAction(ok ? scopedTypings : []); - }); - } - }; TypingsInstaller.prototype.ensureDirectoryExists = function (directory, host) { var directoryName = ts.getDirectoryPath(directory); if (!host.directoryExists(directoryName)) { @@ -7537,9 +6918,11 @@ var ts; if (_this.log.isEnabled()) { _this.log.writeLine("Got FS notification for " + f + ", handler is already invoked '" + isInvoked + "'"); } - _this.sendResponse({ projectName: projectName, kind: "invalidate" }); - isInvoked = true; - }); + if (!isInvoked) { + _this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate }); + isInvoked = true; + } + }, 2000); watchers.push(w); } this.projectWatchers[projectName] = watchers; @@ -7550,19 +6933,20 @@ var ts; typingOptions: request.typingOptions, compilerOptions: request.compilerOptions, typings: typings, - kind: "set" + unresolvedImports: request.unresolvedImports, + kind: server.ActionSet }; }; - TypingsInstaller.prototype.execAsync = function (requestKind, requestId, args, cwd, onRequestCompleted) { - this.pendingRunRequests.unshift({ requestKind: requestKind, requestId: requestId, args: args, cwd: cwd, onRequestCompleted: onRequestCompleted }); + TypingsInstaller.prototype.installTypingsAsync = function (requestId, args, cwd, onRequestCompleted) { + this.pendingRunRequests.unshift({ requestId: requestId, args: args, cwd: cwd, onRequestCompleted: onRequestCompleted }); this.executeWithThrottling(); }; 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.executeRequest(request.requestKind, request.requestId, request.args, request.cwd, function (ok) { + this_1.installWorker(request.requestId, request.args, request.cwd, function (ok) { _this.inFlightRequestCount--; request.onRequestCompleted(ok); _this.executeWithThrottling(); @@ -7570,7 +6954,7 @@ var ts; }; var this_1 = this; while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) { - _loop_1(); + _loop_2(); } }; return TypingsInstaller; @@ -7607,22 +6991,56 @@ var ts; return "npm"; } } + function loadTypesRegistryFile(typesRegistryFilePath, host, log) { + if (!host.fileExists(typesRegistryFilePath)) { + if (log.isEnabled()) { + log.writeLine("Types registry file '" + typesRegistryFilePath + "' does not exist"); + } + return ts.createMap(); + } + try { + var content = JSON.parse(host.readFile(typesRegistryFilePath)); + return ts.createMap(content.entries); + } + catch (e) { + if (log.isEnabled()) { + log.writeLine("Error when loading types registry file '" + typesRegistryFilePath + "': " + e.message + ", " + e.stack); + } + return ts.createMap(); + } + } + var TypesRegistryPackageName = "types-registry"; + function getTypesRegistryFileLocation(globalTypingsCacheLocation) { + return ts.combinePaths(ts.normalizeSlashes(globalTypingsCacheLocation), "node_modules/" + TypesRegistryPackageName + "/index.json"); + } var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); - function NodeTypingsInstaller(globalTypingsCacheLocation, throttleLimit, log) { - var _this = _super.call(this, globalTypingsCacheLocation, ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; - _this.installTypingHost = ts.sys; + function NodeTypingsInstaller(globalTypingsCacheLocation, throttleLimit, telemetryEnabled, log) { + var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, telemetryEnabled, log) || this; if (_this.log.isEnabled()) { _this.log.writeLine("Process id: " + process.pid); } _this.npmPath = getNPMLocation(process.argv[0]); - _this.exec = require("child_process").exec; - _this.httpGet = require("http").get; + var execSync; + (_a = require("child_process"), _this.exec = _a.exec, execSync = _a.execSync, _a); + _this.ensurePackageDirectoryExists(globalTypingsCacheLocation); + try { + if (_this.log.isEnabled()) { + _this.log.writeLine("Updating " + TypesRegistryPackageName + " npm package..."); + } + execSync(_this.npmPath + " install " + TypesRegistryPackageName, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); + } + catch (e) { + if (_this.log.isEnabled()) { + _this.log.writeLine("Error updating " + TypesRegistryPackageName + " package: " + e.message); + } + } + _this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), _this.installTypingHost, _this.log); return _this; + var _a; } - NodeTypingsInstaller.prototype.init = function () { + NodeTypingsInstaller.prototype.listen = function () { var _this = this; - _super.prototype.init.call(this); process.on("message", function (req) { switch (req.kind) { case "discover": @@ -7642,66 +7060,26 @@ var ts; this.log.writeLine("Response has been sent."); } }; - NodeTypingsInstaller.prototype.executeRequest = function (requestKind, requestId, args, cwd, onRequestCompleted) { + NodeTypingsInstaller.prototype.installWorker = function (requestId, args, cwd, onRequestCompleted) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("#" + requestId + " executing " + requestKind + ", arguments'" + JSON.stringify(args) + "'."); - } - switch (requestKind) { - case typingsInstaller.NpmViewRequest: - { - ts.Debug.assert(args.length === 1); - var url_1 = "http://registry.npmjs.org/@types%2f" + args[0]; - var start_2 = Date.now(); - this.httpGet(url_1, function (response) { - var ok = false; - if (_this.log.isEnabled()) { - _this.log.writeLine(requestKind + " #" + requestId + " request to " + url_1 + ":: status code " + response.statusCode + ", status message '" + response.statusMessage + "', took " + (Date.now() - start_2) + " ms"); - } - switch (response.statusCode) { - case 200: - case 301: - case 302: - ok = true; - break; - } - response.destroy(); - onRequestCompleted(ok); - }).on("error", function (err) { - if (_this.log.isEnabled()) { - _this.log.writeLine(requestKind + " #" + requestId + " query to npm registry failed with error " + err.message + ", stack " + err.stack); - } - onRequestCompleted(false); - }); - } - break; - case typingsInstaller.NpmInstallRequest: - { - var command = this.npmPath + " install " + args.join(" ") + " --save-dev"; - var start_3 = Date.now(); - this.exec(command, { cwd: cwd }, function (_err, stdout, stderr) { - if (_this.log.isEnabled()) { - _this.log.writeLine(requestKind + " #" + requestId + " took: " + (Date.now() - start_3) + " ms" + ts.sys.newLine + "stdout: " + stdout + ts.sys.newLine + "stderr: " + stderr); - } - onRequestCompleted(!!stdout); - }); - } - break; - default: - ts.Debug.assert(false, "Unknown request kind " + requestKind); + this.log.writeLine("#" + requestId + " with arguments'" + JSON.stringify(args) + "'."); } + var command = this.npmPath + " install " + args.join(" ") + " --save-dev"; + var start = Date.now(); + this.exec(command, { cwd: cwd }, function (err, stdout, stderr) { + if (_this.log.isEnabled()) { + _this.log.writeLine("npm install #" + requestId + " took: " + (Date.now() - start) + " ms" + ts.sys.newLine + "stdout: " + stdout + ts.sys.newLine + "stderr: " + stderr); + } + onRequestCompleted(!err); + }); }; return NodeTypingsInstaller; }(typingsInstaller.TypingsInstaller)); typingsInstaller.NodeTypingsInstaller = NodeTypingsInstaller; - function findArgument(argumentName) { - var index = ts.sys.args.indexOf(argumentName); - return index >= 0 && index < ts.sys.args.length - 1 - ? ts.sys.args[index + 1] - : undefined; - } - var logFilePath = findArgument("--logFile"); - var globalTypingsCacheLocation = findArgument("--globalTypingsCacheLocation"); + var logFilePath = server.findArgument(server.Arguments.LogFile); + var globalTypingsCacheLocation = server.findArgument(server.Arguments.GlobalCacheLocation); + var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry); var log = new FileLog(logFilePath); if (log.isEnabled()) { process.on("uncaughtException", function (e) { @@ -7714,10 +7092,8 @@ var ts; } process.exit(0); }); - var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, 5, log); - installer.init(); + var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, 5, telemetryEnabled, log); + installer.listen(); })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); - -//# sourceMappingURL=typingsInstaller.js.map diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8f05f5f4e9f..396715bfa45 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17257,11 +17257,15 @@ namespace ts { function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type { Debug.assert(languageVersion < ScriptTarget.ES2015); - // After we remove all types that are StringLike, we will know if there was a string constituent - // based on whether the remaining type is the same as the initial type. let arrayType = arrayOrStringType; if (arrayOrStringType.flags & TypeFlags.Union) { - arrayType = getUnionType(filter((arrayOrStringType as UnionType).types, t => !(t.flags & TypeFlags.StringLike)), /*subtypeReduction*/ true); + // After we remove all types that are StringLike, we will know if there was a string constituent + // based on whether the result of filter is a new array. + const arrayTypes = (arrayOrStringType as UnionType).types; + const filteredTypes = filter(arrayTypes, t => !(t.flags & TypeFlags.StringLike)); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); + } } else if (arrayOrStringType.flags & TypeFlags.StringLike) { arrayType = neverType; diff --git a/tests/baselines/reference/forOfStringConstituents.js b/tests/baselines/reference/forOfStringConstituents.js new file mode 100644 index 00000000000..0f0d86d8cc6 --- /dev/null +++ b/tests/baselines/reference/forOfStringConstituents.js @@ -0,0 +1,15 @@ +//// [forOfStringConstituents.ts] +interface A { x: 0; y: C[]; } +interface B { x: 1; y: CD[]; } +interface C { x: 2; } +interface D { x: 3; } +type AB = A | B; +type CD = C | D; +declare let x: AB, y: CD; +for (y of x.y); + +//// [forOfStringConstituents.js] +for (var _i = 0, _a = x.y; _i < _a.length; _i++) { + y = _a[_i]; + ; +} diff --git a/tests/baselines/reference/forOfStringConstituents.symbols b/tests/baselines/reference/forOfStringConstituents.symbols new file mode 100644 index 00000000000..226f8e35a55 --- /dev/null +++ b/tests/baselines/reference/forOfStringConstituents.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/forOfStringConstituents.ts === +interface A { x: 0; y: C[]; } +>A : Symbol(A, Decl(forOfStringConstituents.ts, 0, 0)) +>x : Symbol(A.x, Decl(forOfStringConstituents.ts, 0, 13)) +>y : Symbol(A.y, Decl(forOfStringConstituents.ts, 0, 19)) +>C : Symbol(C, Decl(forOfStringConstituents.ts, 1, 30)) + +interface B { x: 1; y: CD[]; } +>B : Symbol(B, Decl(forOfStringConstituents.ts, 0, 29)) +>x : Symbol(B.x, Decl(forOfStringConstituents.ts, 1, 13)) +>y : Symbol(B.y, Decl(forOfStringConstituents.ts, 1, 19)) +>CD : Symbol(CD, Decl(forOfStringConstituents.ts, 4, 16)) + +interface C { x: 2; } +>C : Symbol(C, Decl(forOfStringConstituents.ts, 1, 30)) +>x : Symbol(C.x, Decl(forOfStringConstituents.ts, 2, 13)) + +interface D { x: 3; } +>D : Symbol(D, Decl(forOfStringConstituents.ts, 2, 21)) +>x : Symbol(D.x, Decl(forOfStringConstituents.ts, 3, 13)) + +type AB = A | B; +>AB : Symbol(AB, Decl(forOfStringConstituents.ts, 3, 21)) +>A : Symbol(A, Decl(forOfStringConstituents.ts, 0, 0)) +>B : Symbol(B, Decl(forOfStringConstituents.ts, 0, 29)) + +type CD = C | D; +>CD : Symbol(CD, Decl(forOfStringConstituents.ts, 4, 16)) +>C : Symbol(C, Decl(forOfStringConstituents.ts, 1, 30)) +>D : Symbol(D, Decl(forOfStringConstituents.ts, 2, 21)) + +declare let x: AB, y: CD; +>x : Symbol(x, Decl(forOfStringConstituents.ts, 6, 11)) +>AB : Symbol(AB, Decl(forOfStringConstituents.ts, 3, 21)) +>y : Symbol(y, Decl(forOfStringConstituents.ts, 6, 18)) +>CD : Symbol(CD, Decl(forOfStringConstituents.ts, 4, 16)) + +for (y of x.y); +>y : Symbol(y, Decl(forOfStringConstituents.ts, 6, 18)) +>x.y : Symbol(y, Decl(forOfStringConstituents.ts, 0, 19), Decl(forOfStringConstituents.ts, 1, 19)) +>x : Symbol(x, Decl(forOfStringConstituents.ts, 6, 11)) +>y : Symbol(y, Decl(forOfStringConstituents.ts, 0, 19), Decl(forOfStringConstituents.ts, 1, 19)) + diff --git a/tests/baselines/reference/forOfStringConstituents.types b/tests/baselines/reference/forOfStringConstituents.types new file mode 100644 index 00000000000..2bd2a1abd4e --- /dev/null +++ b/tests/baselines/reference/forOfStringConstituents.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/forOfStringConstituents.ts === +interface A { x: 0; y: C[]; } +>A : A +>x : 0 +>y : C[] +>C : C + +interface B { x: 1; y: CD[]; } +>B : B +>x : 1 +>y : CD[] +>CD : CD + +interface C { x: 2; } +>C : C +>x : 2 + +interface D { x: 3; } +>D : D +>x : 3 + +type AB = A | B; +>AB : AB +>A : A +>B : B + +type CD = C | D; +>CD : CD +>C : C +>D : D + +declare let x: AB, y: CD; +>x : AB +>AB : AB +>y : CD +>CD : CD + +for (y of x.y); +>y : CD +>x.y : C[] | CD[] +>x : AB +>y : C[] | CD[] + diff --git a/tests/cases/compiler/forOfStringConstituents.ts b/tests/cases/compiler/forOfStringConstituents.ts new file mode 100644 index 00000000000..224fb5396bd --- /dev/null +++ b/tests/cases/compiler/forOfStringConstituents.ts @@ -0,0 +1,8 @@ +interface A { x: 0; y: C[]; } +interface B { x: 1; y: CD[]; } +interface C { x: 2; } +interface D { x: 3; } +type AB = A | B; +type CD = C | D; +declare let x: AB, y: CD; +for (y of x.y); \ No newline at end of file